Registry / serialization / min-dash

min-dash

JSON →
library5.0.0jsnpmunverified

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.

npm install min-dash
INSTALL
IMPORT
SIG · MIN-DASH
M
min-dash
serializationjavascriptv5.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

find
import { find } from 'min-dash';
const { find } = require('min-dash');
Min-dash v5.0.0 and later are ESM-only. CommonJS `require` will result in an error. For tree-shaking, import individual utilities.
* as minDash
import * as minDash from 'min-dash';
const minDash = require('min-dash');
This imports all utilities under a namespace. While functional, it might hinder tree-shaking if your bundler isn't configured for it. ESM-only since v5.0.0.
assign
import { assign } from 'min-dash';
import assign from 'min-dash/lib/assign';
All utilities are exported directly from the main package entry point. Importing from internal paths (`lib/assign`) is discouraged and not guaranteed to be stable across versions. ESM-only since v5.0.0.

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 }
Debug
Known issues
breakingMin-dash v5.0.0 and later are exclusively ESM (ECMAScript Modules). Projects using CommonJS (`require()`) must either migrate to ESM or stick to min-dash v4.x.x.
fix
Migrate your project to use ESM imports (`import ... from 'min-dash';`) and ensure your `package.json` has `"type": "module"` or files use `.mjs` extension. For CommonJS-only environments, use `min-dash@^4.0.0`.
affects: >=5.0.0
gotchaWhen using `min-dash` with module bundlers, ensure your setup correctly applies tree-shaking to only include the specific utilities your application requires. Unoptimized bundling can lead to larger than necessary bundle sizes.
fix
Modern bundlers like Webpack, Rollup, or esbuild usually handle tree-shaking automatically for ESM imports. If using CommonJS, consider tools like `common-shake` (though not applicable for v5+).
affects: >=1.0.0
gotchaPrior to v4.2.2, some language utilities might not gracefully handle `undefined` inputs, potentially leading to runtime errors. Specifically, `findIndex` had a type definition fix in v4.2.2 and `isNil`/`isArray` in v4.2.1.
fix
Upgrade to `min-dash@^4.2.2` or newer to ensure robust handling of `undefined` inputs and correct type definitions across all utilities.
affects: <4.2.2
Errors
Common errors & fixes
ReferenceError: require is not defined in ES module scope
Attempting to use CommonJS `require()` syntax in an environment where min-dash v5.0.0+ is loaded as an ES Module.
fix
Switch to ESM `import` statements: `import { utility } from 'min-dash';`.
SyntaxError: Named export 'find' not found. The requested module 'min-dash' does not provide an export named 'find'.
This error occurs if your project is configured as CommonJS, but attempts to import `min-dash@^5.0.0` using ESM `import` syntax, or if a bundler isn't correctly resolving ESM exports for a CJS project.
fix
Ensure your project is configured for ESM (`"type": "module"` in `package.json`) when using `min-dash@^5.0.0`. Alternatively, if you must use CommonJS, downgrade to `min-dash@^4.0.0`.
TypeError: 'this' is undefined or TypeError: Cannot read properties of undefined (reading 'property')
This can occur when passing `null` or `undefined` as a target object to `assign` or other object manipulation functions, especially if not explicitly handling such cases or if expecting a specific object structure.
fix
Always provide a valid object as the first argument to `assign` (e.g., `assign({}, source)`). Ensure inputs to other utilities are of the expected type, or add explicit checks (`if (input == null) return defaultValue;`) where necessary.
Upgrade
Version history
5.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
min-dash — npm install min-dash · libregistry