RunKit + npm: deepmerge

node v15.14.0
version: master
endpointsharetweet
const deepmerge = require("deepmerge"); const oneVariable = { "default": { "init": { "body": { "hello": "ads", "hi": "2", "password1": "s", }, }, }, }; const twoVariable = { "default": { "init": { "body": { "hello": "ads", "password1": "s", }, }, }, }; const customMerge = () => (A, B) => { const mergedResult = deepmerge(A, B, { customMerge }); for (const keyA of Object.keys(A)) { if (!Object.prototype.hasOwnProperty.call(B, keyA)) { delete mergedResult[keyA]; } } return mergedResult; }; const result = customMerge()( oneVariable, twoVariable ); console.log(result);
Created from: https://npm.runkit.com/deepmerge
Loading…

no comments

    sign in to comment