Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

deep-extend

unclechu74.5mMIT0.6.0TypeScript support: definitely-typed

Recursive object extending

deep-extend, extend, deep, recursive, xtend, clone, merge, json

readme

Deep Extend

Recursive object extending.

Build Status

NPM

Install

$ npm install deep-extend

Usage

var deepExtend = require('deep-extend');
var obj1 = {
  a: 1,
  b: 2,
  d: {
    a: 1,
    b: [],
    c: { test1: 123, test2: 321 }
  },
  f: 5,
  g: 123,
  i: 321,
  j: [1, 2]
};
var obj2 = {
  b: 3,
  c: 5,
  d: {
    b: { first: 'one', second: 'two' },
    c: { test2: 222 }
  },
  e: { one: 1, two: 2 },
  f: [],
  g: (void 0),
  h: /abc/g,
  i: null,
  j: [3, 4]
};

deepExtend(obj1, obj2);

console.log(obj1);
/*
{ a: 1,
  b: 3,
  d:
   { a: 1,
     b: { first: 'one', second: 'two' },
     c: { test1: 123, test2: 222 } },
  f: [],
  g: undefined,
  c: 5,
  e: { one: 1, two: 2 },
  h: /abc/g,
  i: null,
  j: [3, 4] }
*/

Unit testing

$ npm test

Changelog

CHANGELOG.md

Any issues?

Please, report about issues here.

License

MIT

changelog

Changelog

v0.6.0

  • Updated "devDependencies" versions to fix vulnerability alerts
  • Dropped support of io.js and node.js v0.12.x and lower since new versions of "devDependencies" couldn't work with those old node.js versions (minimal supported version of node.js now is v4.0.0)

v0.5.1

  • Fix prototype pollution vulnerability (thanks to @mwakerman for the PR)
  • Avoid using deprecated Buffer API (thanks to @ChALkeR for the PR)

v0.5.0

  • Auto-testing provided by Travis CI;
  • Support older Node.JS versions (v0.11.x and v0.10.x);
  • Removed tests files from npm package.

v0.4.2

  • Fix for null as an argument.

v0.4.1

  • Removed test code from npm package (see pull request #21);
  • Increased minimal version of Node from 0.4.0 to 0.12.0 (because can't run tests on lesser version anyway).

v0.4.0

  • WARNING! Broken backward compatibility with v0.3.x;
  • Fixed bug with extending arrays instead of cloning;
  • Deep cloning for arrays;
  • Check for own property;
  • Fixed some documentation issues;
  • Strict JS mode.