Methods ^
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);
Calculate percentage of number
import { calculatePercentage } from "@ursarik/utils";
console.log(calculatePercentage(200, 20)); // 40
Generates a random integer from min to max (exclusive).
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