jsprim is a utility library focused on fundamental operations for JavaScript primitive types and common object manipulations. It provides functions for deep cloning, thorough deep equality comparisons, and efficient inspection/transformation of object structures, including an O(1) `isEmpty` check and memory-efficient `flattenIter` for traversing deeply nested objects without materializing the full result array. The current stable version is 2.0.2, with the last update approximately four years ago. It targets older Node.js environments (originally requiring Node.js >=0.6.0) and uses the CommonJS module system, making it suitable for legacy projects or environments where explicit CJS interop is managed.
npm install jsprimVerified import paths — ran on the pinned version, not inferred.
Demonstrates core utilities like deepCopy, deepEqual, isEmpty, pluck for nested property access, and flattenIter for efficient object traversal without materializing full arrays.
Be mindful of the `depth === 0` edge case when using `flattenObject`. If consistent iteration behavior is required, especially for `depth === 0`, `flattenIter` might be a more predictable choice, or ensure explicit handling for the `flattenObject` output when `depth` is 0.
Ensure you are using `require()` for importing `jsprim` in Node.js environments. If using in an ES module context, you may need to use `import * as jsprim from 'jsprim'` or configure your build system (e.g., Babel, webpack) for CommonJS interop.
Evaluate the library's functionality against your specific project requirements and Node.js version. Consider auditing its source if used in security-sensitive contexts, or look for more actively maintained alternatives if up-to-date features and support are critical.
Use CommonJS destructuring: `const { deepCopy } = require('jsprim');`If `jsprim` is the only CJS dependency, consider `import * as jsprim from 'jsprim';` if you're in an ES module context. Otherwise, ensure your file is treated as CommonJS (e.g., by using `.cjs` extension or `"type": "commonjs"` in package.json).
Ensure the `depth` argument for `flattenObject` or `flattenIter` is always a non-negative integer (0 or greater).
No dependency data recorded yet.