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.
A naive diff algorithm based on the unique key path of each value in an Object / JSON
A naive diff algorithm based on the unique key path of each value in an Object / JSON
$ npm install flat-diff --save
Given:
import diff from 'flat-diff';
const base = {
a: [1, 2, { b: 1 }, 4, 5, 6],
b: 'test',
c: 'prev'
};
const target = {
a: [1, 2, { b: 2 }, 4, 6],
b: 'test 2',
d: 'new'
};
const metadata = diff(base, target);
will give a result of:
const metadata = [
{ path: 'a.0', type: 'same', value: 1 },
{ path: 'a.1', type: 'same', value: 2 },
{ path: 'a.2.b', type: 'put', prev: 1, value: 2 },
{ path: 'a.3', type: 'same', value: 4 },
{ path: 'a.4', type: 'put', prev: 5, value: 6 },
{ path: 'a.5', type: 'del', value: 6 },
{ path: 'b', type: 'put', prev: 'test', value: 'test 2' },
{ path: 'c', type: 'del', value: 'prev' },
{ path: 'd', type: 'post', value: 'new' }
];
// Note: path keys will be sorted.
Due to how keys are generated, if you have an array and object with number keys in the same path, there will be a conflict.
i.e.
// object
{
a: {
'0': 'b',
'1': 'c'
}
}
// array
{
a: ['b', 'c']
}
// both formats above will result in similar paths:
[
{path: 'a.0', value: 'b'},
{path: 'a.1', value: 'c'}
]
flat-diff
is MIT licensed
FAQs
A naive diff algorithm based on the unique key path of each value in an Object / JSON
The npm package flat-diff receives a total of 0 weekly downloads. As such, flat-diff popularity was classified as not popular.
We found that flat-diff 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.