Skip to content

modern-fnsModern JavaScript utility library

145 modular, immutable, tree-shakeable utilities for JavaScript and TypeScript. Zero runtime dependencies. A lightweight alternative to Lodash.

Install ​

bash
npm install modern-fns
ts
import { groupBy, set, diff, slugify, currency } from 'modern-fns';

groupBy(orders, 'status'); // { paid: [...], pending: [...] }
set(state, 'user.address.city', 'Kochi'); // immutable — `state` untouched
diff(pristine, form); // [{ path: 'name', type: 'changed', ... }]
slugify('Hello Vue World!'); // 'hello-vue-world'
currency(1299.5, 'INR', 'en-IN'); // '₹1,299.50'

Ten focused modules ​

ModuleWhat it covers
arraychunk, unique, groupBy, indexBy, partition, sortBy, orderBy, zip, range, diffArray
objectget, set, has, unset, pick, omit, deepClone, deepMerge, isEqual, flattenObject
diffstructural diffs for dirty checking, audit logs, PATCH bodies and undo/redo
stringslugify, camelCase, kebabCase, truncate, initials, mask, stripHtml, isEmail
numberclamp, decimal-safe round, percentage, formatNumber, abbreviate, currency, tax
urlparseUrl, buildUrl, setQuery, mergeQuery, removeHash, joinUrl, isSameUrl
queryparse, stringify, get, set, toggle, parseArray — a dependency-free qs alternative
valuetoNumber, toBoolean, toDate, toArray plus typed guards for untrusted input
functionalpipe, compose, debounce, throttle, memoize, once, tryCatch, tap
collectionone iteration API across arrays, objects, Map, Set and iterables

Why not just use Lodash? ​

Lodash predates ES modules, TypeScript-by-default and bundle-size budgets. modern-fns is built for those constraints: native ESM with an exports map, types generated from the source rather than a separate @types package, and immutability as a rule rather than a per-function detail.

The full comparison is honest about where Lodash is still the better choice.