Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
advance-json-merge
Advanced tools
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php) [![npm version](https://badge.fury.io/js/advance-json-merge.svg)](https://badge.fury.io/js/advance-json-merge)
Advance json merge
Object.assign
methodnpm install advance-json-merge --save
var advanceMerge = require('advance-json-merge');
Include the pre-built script.
<script src="./dist/index.umd.min.js"></script>
var { mergeWithLevel } = require('advance-json-merge');
const origin = {
e: {
a: {
c: 'o_c',
d: 'o_d'
},
b: {
e: 'o_e'
},
c: {
h: 'o_h'
},
d: {
j: 'o_j'
}
},
f: 1
};
const target = {
e: {
a: {
a: 't_a'
},
b: {
e: 't_e',
f: 't_f'
},
d: 2
},
f: {
a: {},
b: {
c: 't_c',
h: 't_h'
}
}
};
// level 0 merge
const result = mergeWithLevel(origin, target, 0);
expect(result).toEqual(target);
// level 1 merge
const result = mergeWithLevel(origin, target, 1);
expect(result).toEqual(Object.assign({}, origin, target));
// level 2 merge
const result = mergeWithLevel(origin, target, 2);
expect(result).toEqual({
e: {
a: {
a: 't_a'
},
b: {
e: 't_e',
f: 't_f'
},
c: {
h: 'o_h'
},
d: 2
},
f: {
a: {},
b: {
c: 't_c',
h: 't_h'
}
}
});
// level 3+ merge
const levelNum = chance.integer({ min: 3, max: 1000 });
const result = mergeWithLevel(origin, target, levelNum);
expect(result).toEqual({
e: {
a: {
a: 't_a',
c: 'o_c',
d: 'o_d'
},
b: {
e: 't_e',
f: 't_f'
},
c: {
h: 'o_h'
},
d: 2
},
f: {
a: {},
b: {
c: 't_c',
h: 't_h'
}
}
});
npm run build
npm test
npm run doc
then open the generated out/index.html
file in your browser.
MIT.
FAQs
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php) [![npm version](https://badge.fury.io/js/advance-json-merge.svg)](https://badge.fury.io/js/advance-json-merge)
The npm package advance-json-merge receives a total of 8 weekly downloads. As such, advance-json-merge popularity was classified as not popular.
We found that advance-json-merge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.