Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS Helpers

A lightweight, zero-dependency collection of JavaScript utility functions for everyday development.

Features

  • 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

Installation

npm install js-helpers

Usage

import { 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.5

Development

git clone https://github.com/hannyloveworld/js-helpers.git
cd js-helpers
npm install
npm test

License

MIT

About

A lightweight collection of JavaScript utility functions for everyday development

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages