@n1ru4l/json-patch-plus
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

@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);
// logs '{ a: { b: 1 } }'

Readme

Keywords

Package Sidebar

Install

npm i @n1ru4l/json-patch-plus

Weekly Downloads

17,070

Version

0.2.0

License

MIT

Unpacked Size

52.8 kB

Total Files

18

Last publish

Collaborators

  • n1ru4l