Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Deeply merges properties of the provided objects, returns untangled copy (clone)
Javascript (Node + Browser) library that deeply merges properties of the provided objects, returns untangled copy (clone).
$ npm install deeply
$ ender add deeply --use=your_ender_file
– Deeply merges two or more objects.
Node:
var merge = require('deeply');
merge({a: {a1: 1}}, {a: {a2: 2}}); // -> {a: {a1: 1, a2: 2}}
Ender:
$.merge({a: {a1: 1}}, {a: {a2: 2}}); // -> {a: {a1: 1, a2: 2}}
– As degenerated case of merging one object on itself, it's possible to use deeply as deep clone function.
Node:
var merge = require('deeply')
, clone = merge
;
var x = {a: {b: {c: 1}}};
var y = clone(x);
y.a.b.c = 2;
console.log(x.a.b.c); // -> 1
Ender:
var clone = $.merge;
var x = {a: {b: {c: 1}}};
var y = clone(x);
y.a.b.c = 2;
console.log(x.a.b.c); // -> 1
– By default array treated as primitive values and being replaced upon conflict, for more meaningful array merge strategy, provide custom reduce function as last argument.
Node:
var merge = require('deeply');
// default behavior
merge({ a: { b: [0, 2, 4] }}, { a: {b: [1, 3, 5] }}); // -> { a: { b: [1, 3, 5] }}
// custom merge function
function customMerge(a, b)
{
return (a||[]).concat(b);
}
merge({ a: { b: [0, 2, 4] }}, { a: {b: [1, 3, 5] }}, customMerge); // -> { a: { b: [0, 2, 4, 1, 3, 5] }}
Ender:
// default behavior
$.merge({ a: { b: [0, 2, 4] }}, { a: {b: [1, 3, 5] }}); // -> { a: { b: [1, 3, 5] }}
// custom merge function
function customMerge(a, b)
{
return (a||[]).concat(b);
}
$.merge({ a: { b: [0, 2, 4] }}, { a: {b: [1, 3, 5] }}, customMerge); // -> { a: { b: [0, 2, 4, 1, 3, 5] }}
More examples can be found in test/index.js
.
Deeply is licensed under the MIT license.
FAQs
A toolkit for deep structure manipulations, provides deep merge/clone functionality out of the box, and exposes hooks and custom adapters for more control and greater flexibility.
The npm package deeply receives a total of 781 weekly downloads. As such, deeply popularity was classified as not popular.
We found that deeply 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.