extend-shallow is a minimalist JavaScript utility designed to merge the enumerable properties of one or more source objects into a target object. It performs a *shallow* merge, meaning only top-level properties are copied; nested objects or arrays are copied by reference rather than being cloned. The current stable version is 3.0.2, last published in 2017, indicating a mature and stable, but not actively feature-developed, codebase. It primarily targets Node.js environments from version 0.10.0 upwards, supporting CommonJS module syntax. While modern JavaScript environments widely support `Object.assign()` for similar functionality, extend-shallow serves as a lightweight alternative, particularly useful in legacy environments or when a direct, unopinionated shallow merge is explicitly required without the overhead of polyfills or broader compatibility layers. Its key differentiator lies in its focused, single-purpose design, making it a very small footprint utility.
npm install extend-shallowVerified import paths — ran on the pinned version, not inferred.
Illustrates how to perform a basic shallow extension with multiple source objects and how to create a shallow clone, highlighting the reference-copy behavior for nested objects.
For deep merging, consider using libraries specifically designed for deep cloning or merging, such as 'lodash.merge', 'deepmerge', or manually implementing a recursive merge function for controlled behavior.
Always use CommonJS `const extend = require('extend-shallow');` or a default ESM import `import extend from 'extend-shallow';` which Node.js handles via interoperability rules.For new projects or modern environments, prefer `Object.assign()` unless you have a specific requirement for `extend-shallow`'s exact implementation details or need to support extremely legacy JavaScript environments (pre-ES6) without polyfills.
Use a default import for ESM (`import extend from 'extend-shallow';`) or the CommonJS `require` syntax (`const extend = require('extend-shallow');`).Ensure the first argument passed to `extend` is always an object, typically an empty object literal `{}` if you intend to create a new object or an existing object you wish to mutate.No dependency data recorded yet.