Socket
Socket
Sign inDemoInstall

deep-extend

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    deep-extend

Recursive object extending


Version published
Weekly downloads
13M
decreased by-18.12%
Maintainers
1
Install size
9.77 kB
Created
Weekly downloads
 

Package description

What is deep-extend?

The deep-extend npm package is a utility for deep (recursive) extending of the properties of objects. It is useful for merging the contents of multiple objects into one. This can be particularly helpful when dealing with configurations or settings that need to be composed from multiple sources.

What are deep-extend's main functionalities?

Deep Merging of Objects

This feature allows you to merge multiple objects into a single object, combining and overriding properties as necessary. The properties from later objects will override those from earlier ones.

{"const deepExtend = require('deep-extend');
const obj1 = { a: 1, b: { c: 1 } };
const obj2 = { b: { d: 2 } };
const result = deepExtend({}, obj1, obj2);
console.log(result); // Output: { a: 1, b: { c: 1, d: 2 } }}

Other packages similar to deep-extend

Readme

Source

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

Keywords

FAQs

Last updated on 22 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc