lean-utils
v1.0.2
Published
A collection of lightweight utility functions
Readme
lean-utils
Small collection of useful JavaScript utilities extracted from this package's index.js.
Installation
Install the published package:
npm install lean-utilsQuick usage
const { debounce, throttle, deepClone } = require("lean-utils");
const fn = () => console.log("hello");
const t = throttle(fn, 200);
// deep clone example
const o = { a: 1, b: { c: 2 } };
const c = deepClone(o);API
deepClone(value)— deep clones arrays/objects, preserves Date/RegExpdebounce(fn, wait = 100)— debounces a functionthrottle(fn, interval = 100)— throttles a functiononce(fn)— runs a function oncememoize(fn, resolver)— memoizes sync functionsretryAsync(fn, attempts = 3, delay = 100)— retries async functionsformatBytes(bytes, decimals = 2)— human-readable byte sizespick(obj, keys)— picks specified keys from objectomit(obj, keys)— omits specified keys from objecttimeIt(fn)— measures sync function execution timeisObject(v)— simple object type check
