1.1.8 • Published 4 years ago

@ursarik/utils v1.1.8

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

Methods ^

throttle(msec, fn)

Limit function call to 1 per msec

import { throttle } from "@ursarik/utils";
const greeting = name => console.log(`Hi, ${name}`);
const throttledGreeting = throttle(100, greeting);

throttledGreeting("Ursarik"); // Hi, Ursarik
throttledGreeting("Ursarik"); // this call will be ignored because 100 milliseconds have not elapsed

setTimeout(() => {
  throttledGreeting("Ursarik"); // Hi, Ursarik
}, 100);

calculatePercentage(of, percent)

Calculate percentage of number

import { calculatePercentage } from "@ursarik/utils";
console.log(calculatePercentage(200, 20)); // 40

generateRandomNumber(min, max)

Generates a random integer from min to max (exclusive).

multiIncludes(str, values)

Return true if str include at least one value from values

import { multiIncludes } from "@ursarik/utils";
console.log(multiIncludes("just a random string", ["random", "aa"])); // true

sleep(msec)

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago