@n1ru4l/json-patch-plus
This is a slimmed version of jsondiffpatch. All the code is taken from the jsondiffpatch repository, slimmed down, slightly altered and converted to TypeScript.
Huge thanks to @benjamine, who did all the heavy work!
jsondiffpatch
is a replacement for json-patch
that produces more efficient patches!
@n1ru4l/json-patch-plus
has the following changes:
- Full ESM support
- Remove Node.js runtime dependencies introduced through loggers
- Remove class wrapper structures (make code less abstract and smaller)
- Remove text diffing
- Only generate and apply patch deltas (no reversing and visualization)
- Exclude unnecessary data from patch deltas (previous value is replaced with
null
)
For a full description of the delta format please refer to the jsondiffpatch
docs
Install Instructions
yarn install -E @n1ru4l/json-patch-plus
Usage
import { diff, patch } from "@n1ru4l/json-patch-plus";
const delta = diff({
left: {},
right: { a: { b: 1 } },
});
const result = patch({
left: {},
delta,
});
console.log(result);