dann-util

Helpful functions and methods for making an easy code.

Usage no npm install needed!

<script type="module">
  import dannUtil from 'https://cdn.skypack.dev/dann-util';
</script>

README

Let's make code more simply!

❤ Simple functions for easy Coding.

Installation

$ npm install dann-util

Class and Methods

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]

Functions

delay(ms)

Stopping the code for the time.

PARAMETER TYPE OPTIONAL DEFAULT
ms number

random(min, max)

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

unique(array)

Removes duplicates from array.

PARAMETER TYPE OPTIONAL DEFAULT
array string
#### Returns: array

shuffle(array)

Shuffles an array.

PARAMETER TYPE OPTIONAL DEFAULT
array array
#### Returns: array

crFormat(number)

Makes a currency string ("150k").

PARAMETER TYPE OPTIONAL DEFAULT
number number
#### Returns: string

formatNumber(number, locale)

Changes the format of number ("1,000,000").

PARAMETER TYPE OPTIONAL DEFAULT
number number
locale string 🗸 en-us
#### Returns: string

shorten(text, maxLength)

Shorts the text by adding "...".

PARAMETER TYPE OPTIONAL DEFAULT
text string
maxLength number 🗸 2000
#### Returns: string

stringify(object, space)

JSON.stringify, but more simply.

PARAMETER TYPE OPTIONAL DEFAULT
object object
space number 🗸 2
#### Returns: string

Join to us!