JSPM

  • Created
  • Published
  • Downloads 8592
  • Score
    100M100P100Q135527F
  • License MIT

Lightweight solution for merging multiple objects into one. Also it supports deep merge and deep clone

Package Exports

  • putil-merge

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (putil-merge) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

putil-merge

NPM Version NPM Downloads Build Status Test Coverage Dependencies DevDependencies

Lightweight solution for merging multiple objects into one. Also it supports deep merge

Installation

  • npm install putil-merge --save

Usage

merge(target, ...source)

Combines source objects with the target object without deep operation. Also it copies references instead of cloning.

merge.deep(target, ...source)

Combines source objects with the target object with deep operation. Also it copies references instead of cloning.

merge.clone(target, ...source)

Combines source objects with the target object without deep operation. Also it clones values.

merge.deepClone(target, ...source)

Combines source objects with the target object with deep operation. Also it clones values.

const a = {l1a: 1, l1b: '2', l1d: {l2a: 1}};
const b = {l1b: 'b', l1c: 3, l1d: {l2b: {l3a: '2'}}, l1e: [1, 2, 3, 4]};
let o = merge(a, b);

Node Compatibility

  • node >= 6.x;

License

MIT