
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
json-patcher
Advanced tools
Generate a series of instructions to get from an object to another object.
import { diff } from 'json-patcher';
let a = {
'foo': 'bar'
}
let b = {
'bar': 'baz'
}
console.log(diff(a, b));
/*
[
[
"DEL",
[],
"foo"
],
[
"SET",
[
"bar"
],
"baz"
]
]
*/
stringDiff(a, b)Provides a more human readable format of the diff between a and b
import { stringDiff } from 'json-patcher';
let a = {
'foo': 'bar'
}
let b = {
'bar': 'baz'
}
console.log(stringDiff(a, b));
/*
DEL: $ - foo
SET: $.bar - baz
*/
apply(a, instructions)Takes a set of instructions and performs them on an object. Returns the new object.
import { apply } from 'json-patcher';
let a = {
'foo': 'bar'
}
let instructions = [
['DEL', [], 'foo'],
['SET', ['bar'], 'baz']
];
let b = apply(a, instructions)
console.log(b);
/*
{
"bar": "baz"
}
*/
These are just the things I remember, it's all just nice of course :P
The output of diff(a, a) is always an empty set of instructions, which is a noop.
The diff and apply functions both work on primitives. Meaning it can generate instructions for converting an object to a primitive and apply those instructions to get a primitive.
All pairs of the following are tested together:
{'foo': 'bar'}{'foo': {'bar': 'baz': 'bat'}}})FAQs
Either generates diffs or applies diffs between objects in js (json)
We found that json-patcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.