A lightweight, zero-dependency collection of JavaScript utility functions for everyday development.
- Array - chunk, unique, flatten, groupBy, shuffle, difference, intersection, sortBy
- String - capitalize, camelCase, kebabCase, snakeCase, truncate, slugify, escapeHtml
- Object - deepClone, deepMerge, pick, omit, flatten, get, set, mapValues
- Date - format, isBefore, isAfter, addDays, diffInDays, timeAgo
- Validate - isEmail, isUrl, isUUID, isStrongPassword, isHexColor, isCreditCard
- Async - sleep, timeout, retry, parallel, series, debounce, throttle, memoize
- Math - clamp, lerp, average, median, stdDev, fibonacci, factorial, isPrime
npm install js-helpersimport { array, string, object, validate, math } from 'js-helpers';
// Array utilities
array.chunk([1, 2, 3, 4], 2); // [[1, 2], [3, 4]]
array.unique([1, 1, 2, 3]); // [1, 2, 3]
array.groupBy(items, 'type'); // { a: [...], b: [...] }
// String utilities
string.camelCase('hello-world'); // 'helloWorld'
string.kebabCase('helloWorld'); // 'hello-world'
string.slugify('Hello World!'); // 'hello-world'
// Object utilities
object.deepClone({ a: { b: 1 } }); // Deep copy
object.get({ a: { b: 42 } }, 'a.b'); // 42
// Validation
validate.isEmail('test@example.com'); // true
validate.isStrongPassword('P@ss123'); // true
// Math utilities
math.clamp(15, 0, 10); // 10
math.average([1, 2, 3, 4]); // 2.5git clone https://github.com/hannyloveworld/js-helpers.git
cd js-helpers
npm install
npm testMIT