{"id":11328,"library":"min-dash","title":"Min-dash: Minimal Utility Toolbelt","description":"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.","status":"active","version":"5.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/bpmn-io/min-dash","tags":["javascript","lodash","utility","tool","belt","typescript"],"install":[{"cmd":"npm install min-dash","lang":"bash","label":"npm"},{"cmd":"yarn add min-dash","lang":"bash","label":"yarn"},{"cmd":"pnpm add min-dash","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Min-dash v5.0.0 and later are ESM-only. CommonJS `require` will result in an error. For tree-shaking, import individual utilities.","wrong":"const { find } = require('min-dash');","symbol":"find","correct":"import { find } from 'min-dash';"},{"note":"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.","wrong":"const minDash = require('min-dash');","symbol":"* as minDash","correct":"import * as minDash from 'min-dash';"},{"note":"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.","wrong":"import assign from 'min-dash/lib/assign';","symbol":"assign","correct":"import { assign } from 'min-dash';"}],"quickstart":{"code":"import { find, sortBy, assign } from 'min-dash';\n\nconst users = [\n  { id: 1, name: 'Alice', age: 30 },\n  { id: 2, name: 'Bob', age: 25 },\n  { id: 3, name: 'Charlie', age: 35 }\n];\n\n// Find a user based on a condition\nconst oldestUser = find(users, user => user.age > 30);\nconsole.log('Oldest user:', oldestUser); // Output: Oldest user: { id: 3, name: 'Charlie', age: 35 }\n\n// Sort users by a property\nconst sortedUsers = sortBy(users, 'age');\nconsole.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 } ]\n\n// Assign properties from source objects to a target object\nconst defaultOptions = { theme: 'dark', logging: true };\nconst userOptions = { logging: false, debug: true };\nconst mergedOptions = assign({}, defaultOptions, userOptions);\nconsole.log('Merged options:', mergedOptions); // Output: Merged options: { theme: 'dark', logging: false, debug: true }","lang":"typescript","description":"Demonstrates importing and using `find`, `sortBy`, and `assign` utilities for common data manipulation tasks with an emphasis on ESM syntax."},"warnings":[{"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`.","message":"Min-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.","severity":"breaking","affected_versions":">=5.0.0"},{"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+).","message":"When 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to `min-dash@^4.2.2` or newer to ensure robust handling of `undefined` inputs and correct type definitions across all utilities.","message":"Prior 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.","severity":"gotcha","affected_versions":"<4.2.2"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Switch to ESM `import` statements: `import { utility } from 'min-dash';`.","cause":"Attempting to use CommonJS `require()` syntax in an environment where min-dash v5.0.0+ is loaded as an ES Module.","error":"ReferenceError: require is not defined in ES module scope"},{"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`.","cause":"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.","error":"SyntaxError: Named export 'find' not found. The requested module 'min-dash' does not provide an export named 'find'."},{"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.","cause":"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.","error":"TypeError: 'this' is undefined or TypeError: Cannot read properties of undefined (reading 'property')"}],"ecosystem":"npm"}