Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@broofa/merge
Advanced tools
Merge immutable JSON data structures to allow for identity (===) comparisons on deeply-equal subtrees
Merge immutable model state (or any data structure, really), preserving references to unchanged nodes, such that the ===
operation can be used to determine where state has changed. (Useful when dealing with immutable data models such as React+Redux, where ===
is used for exactly this purpose.)
Specifically, given
before
and after
state = merge(before, after)
Then:
assert.deepEqual(state, after)
always passesAnd for any path, [X]
, to an Object or Array within state
:
state[X] === before[X]
where assert.deepEqual(before[X], state[X])
passesstate[X] === after[X]
where no part of after[X]
is equal to before[X]
state[X] === (new Object/Array)
when some, but not all state w/in [X]
has changednpm i @broofa/merge
const assert = require('assert');
const merge = require('@broofa/merge');
const before = {
a: 'hello',
b: 123,
c: {ca: ['zig'], cb: [{a:1}, {b:2}]},
};
const after = {
a: 'world',
b: 123,
c: {ca: ['zig'], cb: [{a:99}, {b:2}]},
};
const state = merge(before, after);
assert.deepEqual(after, state); // Always true
// Where state HAS changed
state === before; // ⇨ false
state.c === before.c; // ⇨ false
state.c.cb === before.c.cb; // ⇨ false
state.c.cb[0] === before.c.cb[0]; // ⇨ false
// Where state HAS NOT changed
state.c.ca === before.c.ca; // ⇨ true
state.c.cb[1] === before.c.cb[1]; // ⇨ true
Markdown generated from src/README_js.md by
FAQs
Merge immutable JSON data structures to allow for identity (===) comparisons on deeply-equal subtrees
The npm package @broofa/merge receives a total of 4 weekly downloads. As such, @broofa/merge popularity was classified as not popular.
We found that @broofa/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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.