cljs-merge
v1.1.1
Published
'cljs-merge' recursively merges two jsons into a unified one.
Downloads
2,106
Maintainers
Readme
cljs-merge
'cljs-merge' recursively merges two jsons into a unified one.
const { merge } = require("cljs-merge")
const js1 = { k1: "v1", k2: "v2", k3: "v3" }
const js2 = { k1: "v1", k2: undefined, k4: "v4", k5: "v5", k6: null }
const res = merge({src:js1, target: js2})
console.log(res);
// { k1: 'v1', k2: 'v2', k3: 'v3', k4: 'v4', k5: 'v5' }
const { merge } = require("cljs-merge")
const js1 = {
key1: "1",
key2: "2",
key3: "3",
key4: "4",
key5: {
key22: null,
key11: "10",
key33: "30"
},
special: "BORA"
}
const js2 = {
key1: "10",
key3: null,
key4: "40",
key5: {
key11: null,
key22: "200",
key33: null
},
key6: "6",
quit: -1
}
const res = merge({src:js1, target:js2})
console.log(res)
// res =>
// {
// key1: "10",
// key2: "2",
// key3: "3",
// key4: "40"
// key5: {
// key11: "10",
// key22: "200",
// key33: "30",
// }
// key6: "6",
// special: "BORA"
// quit: -1
// }
Installation for Node.js
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
If this is a brand new project, make sure to create a package.json
first with
the npm init
command.
Installation is done using the
npm install
command:
$ npm install cljs-merge
Installation for Web Browser
CDN
<script src="https://cdn.jsdelivr.net/npm/[email protected]/cljs-merge.js"></script>
<script>
const cljs = require("cljs-merge")
const js1 = { k1: "v1", k2: "v2", k3: "v3" }
const js2 = { k1: "v1", k2: undefined, k4: "v4", k5: "v5", k6: null }
const res = cljs.merge({src:js1, target: js2})
console.log(res);
// { k1: 'v1', k2: 'v2', k3: 'v3', k4: 'v4', k5: 'v5' }
</script>