🎃 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 = ; 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 = ;// ==> [{ "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.gitcd json-squashnpm installnpm 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