ModernDash

4.0.2 · active · verified Sun Apr 19

ModernDash is a TypeScript-first utility library designed as a performant and lightweight alternative to Lodash, optimized for modern browsers and enhanced developer experience. Currently stable at version 4.0.2, it follows a release cadence driven by feature additions, bug fixes, and security patches, with major versions tied to breaking changes like Node.js version bumps. Key differentiators include its strict TypeScript adherence (no `any` types), ESM-only distribution, tree-shakable design, and a strong focus on outperforming Lodash in most benchmarks while maintaining zero runtime dependencies. It selectively implements only essential utility functions, encouraging the use of native JavaScript alternatives where available, contrasting with Lodash's more comprehensive API surface.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install ModernDash and use fundamental utility functions like `chunk`, `camelCase`, and `merge` in a TypeScript environment.

import { chunk, camelCase, merge } from 'moderndash';

console.log('--- moderndash Quickstart ---');

// Example 1: Chunk an array into smaller arrays
const myArray = [1, 2, 3, 4, 5, 6, 7];
const chunkedArray = chunk(myArray, 3);
console.log('Chunked array:', chunkedArray);
// Expected: [[1, 2, 3], [4, 5, 6], [7]]

// Example 2: Convert a string to camel case
const myString = 'hello world moderndash example';
const camelCasedString = camelCase(myString);
console.log('Camel cased string:', camelCasedString);
// Expected: "helloWorldModerndashExample"

// Example 3: Deep merge objects
const object1 = { 'a': [{ 'b': 2 }, { 'd': 4 }] };
const object2 = { 'a': [{ 'c': 3 }, { 'e': 5 }] };
const mergedObject = merge(object1, object2);
console.log('Merged object:', JSON.stringify(mergedObject, null, 2));
/* Expected (keys merged by index in arrays):
{
  "a": [
    { "b": 2, "c": 3 },
    { "d": 4, "e": 5 }
  ]
}*/

view raw JSON →