1.0.3 • Published 2 years ago

dann-util v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Let's make code more simply!

❤ Simple functions for easy Coding. Written with TypeScript

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.

PARAMETERTYPEOPTIONALDEFAULT
msnumber

random(min, max)

Gives a random number between the specified range. If max not specified, min will be 1.

PARAMETERTYPEOPTIONALDEFAULT
minnumber
maxnumber🗸

Returns: number

unique(array)

Removes duplicates from array.

PARAMETERTYPEOPTIONALDEFAULT
arraystring

Returns: array

shuffle(array)

Shuffles an array.

PARAMETERTYPEOPTIONALDEFAULT
arrayarray

Returns: array

crFormat(number)

Makes a currency string ("150k").

PARAMETERTYPEOPTIONALDEFAULT
numbernumber

Returns: string

formatNumber(number, locale)

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

PARAMETERTYPEOPTIONALDEFAULT
numbernumber
localestring🗸en-us

Returns: string

shorten(text, maxLength)

Shorts the text by adding "...".

PARAMETERTYPEOPTIONALDEFAULT
textstring
maxLengthnumber🗸2000

Returns: string

stringify(object, space)

JSON.stringify, but more simply.

PARAMETERTYPEOPTIONALDEFAULT
objectobject
spacenumber🗸2

Returns: string

remove(array, index, element)

JSON.stringify, but more simply.

PARAMETERTYPEOPTIONALDEFAULT
arrayarray
indexnumber🗸
elementAny🗸

Returns: array

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.3

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago