NPM Smell 🍑💨

trivial and outdated NPM packages

extend-shallow outdated npm logo

Reimplements the native Object.assign() method.

Weekly Downloads
32,523,603
Dependencies
4
Latest Release
8 years ago
Switch to the native implementation.
Outdated
natively supported
since 10 years (chrome, firefox, safari, nodejs)

Dependency Tree

  • extend-shallow @3.0.2 (4)
    • assign-symbols @1.0.0
    • is-extendable @1.0.1 (2)
      • is-plain-object @2.0.4 (1)
        • isobject @3.0.1

About

This dependency reimplements the Object.assign method which is used to shallowly copy properties from one or more source objects to a target object.

It also needs 4 dependencies to do what Object.assign can do natively.

// merge 2 objects
const obj1 = {
    foo: "bar"
};

const obj2 = {
    baz: "qux"
};

const merged = Object.assign({}, obj1, obj2);

console.log(merged); // { foo: "bar", baz: "qux" }

or you can use the spread operator for a more concise syntax:

// merge 2 objects
const obj1 = {
    foo: "bar"
};

const obj2 = {
    baz: "qux"
};

const merged = {
    ...obj1,
    ...obj2
};

console.log(merged); // { foo: "bar", baz: "qux" }

The spread operator is supported by all modern browsers and Node.js versions since ES2018. Object.assign is supported since ES6 (2015).