json-squash
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

🎃 json-squash

Squash JSON-Patch operations patch into a mathematically equivalent smaller patch

Installation

Using npm:

npm install json-squash --save

Using yarn:

yarn add json-squash

Usage:

Using CommonJS:

const squash = require('json-squash');
 
const patch = [
  { "op": "add", "path": "/a/b/c", "value": 1},
  { "op": "replace", "path": "/a/b/c", "value": 12 },
  { "op": "replace", "path": "/a/b/c", "value": 123 },
  { "op": "replace", "path": "/a/b/c", "value": 1234 },
  { "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
  { "op": "replace", "path": "/a/b/d", "value": 12345 },
];
 
const squashed = squash(patch);
// ==> [{ "op": "add", "path": "/a/b/d", "value": 12345 }]

Testing

json-squash uses ava test runner. To test,

git clone https://github.com/alshakero/json-squash.git
cd json-squash
npm install
npm test

Contributing

  • Fork this repo.
  • Run npm install.
  • Run tests before any modifications to make sure they run.
  • Modify.
  • Test again. Please add suites if your modifications add new functionality.
  • Send a PR request.
  • Receive big thanks!

Author

Omar Alshaker

License

MIT 2017

Readme

Keywords

Package Sidebar

Install

npm i json-squash

Weekly Downloads

15

Version

0.0.3

License

MIT

Last publish

Collaborators

  • alshakero