Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smikodanic/nodejs-alat
Handy libraries for NodeJS.
https://github.com/smikodanic/nodejs-alat
Last synced: 15 days ago
JSON representation
Handy libraries for NodeJS.
- Host: GitHub
- URL: https://github.com/smikodanic/nodejs-alat
- Owner: smikodanic
- License: other
- Created: 2022-08-13T13:36:26.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-16T09:26:20.000Z (over 2 years ago)
- Last Synced: 2024-12-19T13:32:18.968Z (21 days ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nodejs-alat
> Handy libraries for NodeJS.## Installation
```bash
$ npm install --save nodejs-alat
```## Howto
```javascript
/*** NodeJS script ***/
const { rand, StringExt } = require('nodejs-alat');
```## API
### /************ Rand ***********/
*Random library.*#### integerBetween(min, max) :number
Generate random integer number between min and max number.#### floatBetween(min, max, dec) :number
Generate random float number between min and max number with dec decimal places.#### shuffleArray(arr) :array
Randomize (shuffle) elements in array.#### rndm() :number
Generate random number.### /************ StringExt ***********/
*Extended String methods.*```javascript
const { StringExt } = require('nodejs-alat');
new StringExt();// now all strings are extended with the methods, for example:
const str = 'some string'.rmspaces(); // somestring
```#### String.fspaces()
Format empty spaces. Remove empty spaces from left and right and replace it with one empty space inside string.
Replace tab, newline with one empty space.#### String.rmspaces()
Remove empty spaces from left and right and replace it with one empty space inside string.
Replace multiple newlines with only one, for example \n\n\n -> \n.#### String.price2number
Convert price string to number.
```
2,123.00 -> 21123.00
2.123,13 -> 21123.13
``````javascript
const { StringExt } = require('../index.js');
new StringExt();// const str = '3,212.127'; // 3212.13
const str = '3.212,12';
// const str = '212.12';
// const str = '2123';const price = str.price2number();
console.log(typeof price, price); // number 3212.13
```### License
The software licensed under [AGPL-3](LICENSE).