❤ Simple functions for easy Coding.
$ npm install dann-util
const Util = require("dann-util");
// const { delay, unique } = require("dann-util");
await Util.delay(5000);
const uniqueArray = Util.unique([1, 1, 5, 1, 6, 7, 7, 5, 9, 5]);
console.log(uniqueArray);
// After 5 seconds, Output: [1, 5, 6, 7, 9]
Stopping the code for the time.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
ms | number |
Gives a random number between the specified range.
If max
not specified, min
will be 1
.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
min | number | ||
max | number | 🗸 |
Returns: number
Removes duplicates from array.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
array | string |
Returns: array
Shuffles an array.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
array | array |
Returns: array
Makes a currency string ("150k").
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
number | number |
Returns: string
Changes the format of number ("1,000,000").
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
number | number | ||
locale | string | 🗸 | en-us |
Returns: string
Shorts the text by adding "...".
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
text | string | ||
maxLength | number | 🗸 | 2000 |
Returns: string
JSON.stringify, but more simply.
PARAMETER | TYPE | OPTIONAL | DEFAULT |
---|---|---|---|
object | object | ||
space | number | 🗸 | 2 |