Min-dash: Minimal Utility Toolbelt

5.0.0 · active · verified Sun Apr 19

Min-dash is a lean, battle-tested utility belt providing a curated selection of essential functions for JavaScript and TypeScript development, particularly within the bpmn.io ecosystem. It differentiates itself by its minimal bundle footprint (under 2 kB gzipped), ES2015 compatibility, and performance-optimized utilities for common operations like sorting and unions. The library ships with comprehensive TypeScript type definitions, ensuring a robust development experience. The current stable version is `5.0.0`, published in February 2024. The project maintains an active release cadence, addressing bug fixes and improvements in minor versions, with major releases introducing significant architectural shifts, such as the transition to an ESM-only distribution. It encourages the use of modern module bundlers for optimal tree-shaking.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing and using `find`, `sortBy`, and `assign` utilities for common data manipulation tasks with an emphasis on ESM syntax.

import { find, sortBy, assign } from 'min-dash';

const users = [
  { id: 1, name: 'Alice', age: 30 },
  { id: 2, name: 'Bob', age: 25 },
  { id: 3, name: 'Charlie', age: 35 }
];

// Find a user based on a condition
const oldestUser = find(users, user => user.age > 30);
console.log('Oldest user:', oldestUser); // Output: Oldest user: { id: 3, name: 'Charlie', age: 35 }

// Sort users by a property
const sortedUsers = sortBy(users, 'age');
console.log('Sorted users:', sortedUsers); // Output: Sorted users: [ { id: 2, name: 'Bob', age: 25 }, { id: 1, name: 'Alice', age: 30 }, { id: 3, name: 'Charlie', age: 35 } ]

// Assign properties from source objects to a target object
const defaultOptions = { theme: 'dark', logging: true };
const userOptions = { logging: false, debug: true };
const mergedOptions = assign({}, defaultOptions, userOptions);
console.log('Merged options:', mergedOptions); // Output: Merged options: { theme: 'dark', logging: false, debug: true }

view raw JSON →