{"id":15493027,"url":"https://github.com/alshakero/json-squash","last_synced_at":"2025-06-23T17:03:00.704Z","repository":{"id":57285281,"uuid":"92656270","full_name":"alshakero/json-squash","owner":"alshakero","description":"Squash JSON-Patch operations patch into a mathematically equivalent yet smaller patch","archived":false,"fork":false,"pushed_at":"2020-05-13T18:02:20.000Z","size":65,"stargazers_count":14,"open_issues_count":4,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-14T15:08:43.366Z","etag":null,"topics":["compress","compression","json-patch","rfc6902"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alshakero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-28T11:09:33.000Z","updated_at":"2024-10-22T03:27:07.000Z","dependencies_parsed_at":"2022-09-09T00:41:11.211Z","dependency_job_id":null,"html_url":"https://github.com/alshakero/json-squash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshakero%2Fjson-squash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshakero%2Fjson-squash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshakero%2Fjson-squash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alshakero%2Fjson-squash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alshakero","download_url":"https://codeload.github.com/alshakero/json-squash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250078293,"owners_count":21371140,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compress","compression","json-patch","rfc6902"],"created_at":"2024-10-02T08:03:37.298Z","updated_at":"2025-04-22T19:46:20.686Z","avatar_url":"https://github.com/alshakero.png","language":"JavaScript","readme":"# 🎃 json-squash\n\n\u003e Squash JSON-Patch operations patch into a mathematically equivalent smaller patch. Shines the most for array splice and shift patches. Removing a single element from an array, whererver it is in the array, will produce a single operation 🙌\n\n[![Build Status](https://travis-ci.org/alshakero/json-squash.svg?branch=master)](https://travis-ci.org/alshakero/json-squash)\n\n## Installation\n\nUsing npm:\n```sh\nnpm install json-squash --save\n```\n\nUsing yarn:\n```sh\nyarn add json-squash\n```\n\n\n## Usage:\n\n```js\nconst squash = require('json-squash');\n// or\nimport squash from 'json-squash';\n\nconst patch = [\n  { \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": 1},\n  { \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 12 },\n  { \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 123 },\n  { \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 1234 },\n  { \"op\": \"move\", \"from\": \"/a/b/c\", \"path\": \"/a/b/d\" },\n  { \"op\": \"replace\", \"path\": \"/a/b/d\", \"value\": 12345 },\n];\n\nconst squashed = squash(patch);\n// ==\u003e [{ \"op\": \"add\", \"path\": \"/a/b/d\", \"value\": 12345 }]\n\n\n// array shift\nconst obj = {arr: [1, 2, 3, 4, 5, 6]};\nobj.arr.shift();\n\n// fast-json-patch diff result\nconst patch = [\n  {op: \"replace\", path: \"/arr/0\", value: 2},\n  {op: \"replace\", path: \"/arr/1\", value: 3},\n  {op: \"replace\", path: \"/arr/2\", value: 4},\n  {op: \"replace\", path: \"/arr/3\", value: 5},\n  {op: \"replace\", path: \"/arr/4\", value: 6},\n  {op: \"remove\", path: \"/arr/5\"}\n];\n\nconst squashed = squash(patch);\n// ==\u003e [{ \"op\": \"remove\", \"path\": \"arr/0\" }]\n```\n\n## Testing\n\njson-squash uses [ava](https://github.com/avajs/ava) test runner. To test,\n```sh\ngit clone https://github.com/alshakero/json-squash.git\ncd json-squash\nnpm install\nnpm test\n```\n\n## Contributing\n\n- Fork this repo.\n- Run `npm install`.\n- Run tests before any modifications to make sure they run.\n- Modify.\n- Test again. Please add suites if your modifications add new functionality.\n- Send a PR request.\n- Receive big thanks!\n\n## Author\n\nOmar Alshaker\n\n## License\nMIT 2017\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshakero%2Fjson-squash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falshakero%2Fjson-squash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falshakero%2Fjson-squash/lists"}