deep-assign-v2
v1.0.2
Published
Like Object.assign,but assign deeply if needed.
Downloads
3
Readme
deep-assign-v2
Like Object.assign,but assign deeply if needed.
Installation
npm i deep-assign-v2 -S
yarn add deep-assign-v2
Usage
JavaScript
const deep_assign = require("deep-assign-v2").default;
it("deep assign override", () => {
const objA = {
a: "a",
b: "b",
c: { name: "coco" },
d: { willLost: "anyvalue" }
};
const objB = { a: "newA", b: { name: "banxi", age: 18 }, d: "replace" };
deep_assign(objA, objB);
assert.deepEqual(objA, {
a: "newA",
b: { name: "banxi", age: 18 },
c: { name: "coco" },
d: "replace"
});
});
it("deep assign merge", () => {
const objA = { a: "a", b: { gender: "male" }, c: { name: "coco" } };
const objB = { a: "newA", b: { name: "banxi", age: 18 } };
deep_assign(objA, objB);
assert.deepEqual(objA, {
a: "newA",
b: { name: "banxi", age: 18, gender: "male" },
c: { name: "coco" }
});
});
TypeScript
import "date-assign-v2";
Full check api list
Test
npm run test