Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.