The `empty` utility library, currently at version 0.10.1 (last published over 7 years ago), provides a collection of pre-defined empty objects, arrays, and no-operation functions. Its primary feature is enforcing immutability by applying `Object.freeze` to all returned entities by default. This behavior can be overridden if the `NODE_ENV` environment variable is set to `'production'`. The library was designed primarily for CommonJS environments, explicitly supporting Node.js and older browser bundling workflows via tools like Browserify. Due to its age and lack of recent updates, it does not support modern JavaScript module systems (ESM) or TypeScript natively, requiring manual declarations for type safety. Its key differentiator remains providing a consistent, immutable set of primitive empty values and noop functions.
npm install emptyVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing the `empty` library, accessing various empty types (object, array, function, functionThatReturns), and shows the potential impact of `NODE_ENV='production'` on immutability.
Use `const empty = require('empty');` for all imports. For ESM projects, consider a bundler to transpile, or use Node.js's CJS interoperability with `import empty from 'empty';` after ensuring `package.json` has `"type": "module"` and configuring a CJS default import wrapper.Be aware of your `NODE_ENV` setting. If strict immutability is always required, ensure `NODE_ENV` is never `'production'` when using this library, or manually `Object.freeze` the results if `NODE_ENV` might be `'production'`.
Create a `declarations.d.ts` file with `declare module 'empty' { /* ... */ }` to provide type definitions, or consider using a more modern, maintained alternative with native TypeScript support.For ES Modules, you cannot directly use `require()`. You might need to use dynamic `import('empty')` or `import empty from 'empty';` if your environment supports CJS interop, or convert your module to CJS. The most reliable fix for this package is to ensure the consuming file is CJS or use a bundler.Do not attempt to mutate objects or arrays obtained from `empty` as they are immutable by design. If you need a mutable copy, create one using spread syntax (e.g., `{...empty.object}` or `[...empty.array]`). If you explicitly intend for them to be mutable, ensure `process.env.NODE_ENV` is set to `'production'` when the library is loaded.No dependency data recorded yet.