{"id":19387432,"url":"https://github.com/quentinroy/tiny-merge-patch","last_synced_at":"2025-04-23T23:31:09.725Z","repository":{"id":25701706,"uuid":"105879386","full_name":"QuentinRoy/tiny-merge-patch","owner":"QuentinRoy","description":"An FP-ready implementation of the JSON Merge Patch RFC 7396","archived":false,"fork":false,"pushed_at":"2025-04-21T19:13:56.000Z","size":412,"stargazers_count":4,"open_issues_count":26,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-21T20:28:23.622Z","etag":null,"topics":["7396","json","merge","patch","rfc"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QuentinRoy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-05T10:58:39.000Z","updated_at":"2023-11-03T17:11:22.000Z","dependencies_parsed_at":"2023-10-15T14:53:37.987Z","dependency_job_id":"286201af-8662-44e4-bdc9-1cb4f47ba319","html_url":"https://github.com/QuentinRoy/tiny-merge-patch","commit_stats":{"total_commits":171,"total_committers":5,"mean_commits":34.2,"dds":0.3391812865497076,"last_synced_commit":"ed7d39d434a9fdf0b21ed4ae40eb385da3a98a34"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinRoy%2Ftiny-merge-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinRoy%2Ftiny-merge-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinRoy%2Ftiny-merge-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QuentinRoy%2Ftiny-merge-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QuentinRoy","download_url":"https://codeload.github.com/QuentinRoy/tiny-merge-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250531900,"owners_count":21446078,"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":["7396","json","merge","patch","rfc"],"created_at":"2024-11-10T10:09:14.035Z","updated_at":"2025-04-23T23:31:09.429Z","avatar_url":"https://github.com/QuentinRoy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Tiny Merge Patch\n================\n\n[![Build Status](https://travis-ci.org/QuentinRoy/tiny-merge-patch.svg?branch=master)](https://travis-ci.org/QuentinRoy/tiny-merge-patch)\n[![codecov](https://img.shields.io/codecov/c/github/QuentinRoy/tiny-merge-patch.svg)](https://codecov.io/gh/QuentinRoy/tiny-merge-patch)\n[![dependencies Status](https://david-dm.org/quentinroy/tiny-merge-patch/status.svg)](https://david-dm.org/quentinroy/tiny-merge-patch)\n[![devDependencies Status](https://david-dm.org/quentinroy/tiny-merge-patch/dev-status.svg)](https://david-dm.org/quentinroy/tiny-merge-patch?type=dev)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)\n[![NPM version](https://img.shields.io/npm/v/tiny-merge-patch.svg)](https://www.npmjs.com/package/tiny-merge-patch)\n\nAn implementation of the JSON Merge Patch\n[RFC 7396](http://tools.ietf.org/html/rfc7396): a standard format used to\ndescribe modifications to JSON documents. \n\nThis library complies with the functional programming style: it does not mutate\nthe original target, but recycles what it can. It is particularly appropriate to update a state used by [React](https://reactjs.org), allowing selective re-rendering of the UI.\n\n`tiny-merge-patch` passes all [RFC 7396](http://tools.ietf.org/html/rfc7396) tests.\n\n## Install\n\nInstall the current version (and save it as a dependency):\n\n### npm\n\n```sh\nnpm install tiny-merge-patch --save\n```\n\n## Import\n\n### CommonJs with node\n\n```js\n// Fetch `apply` from the module.\nconst mergePatch = require('tiny-merge-patch').apply;\n```\n\n### ES modules in the browser\n\n```js\n// `apply` is also the default export.\nimport mergePatch from 'https://unpkg.com/tiny-merge-patch/esm/index.js'\n```\n\n## Usage\n\n```js\n// Original document / object.\nconst doc = {\n  a: 'b',\n  c: { d: 'e', f: 'g' },\n  h: { i: 0 }\n};\n\n// JSON merge patch to apply.\nconst patch = {\n  a: 'z',\n  c: { f: null } // null marks deletions.\n};\n\n// Apply the patch.\nconst patchedDoc = mergePatch(doc, patch);\n\n// tiny-merge-patch complies with the RFC specification.\nassert.deepEqual(patchedDoc, {\n  a: 'z',\n  c: { d: 'e' },\n  h: { i: 0 },\n});\n\n// Additionally, it does not mutate the original document...\nassert(patchedDoc !== doc);\n\n// ...nor its content...\nassert(patchedDoc.c !== doc.c);\n\n// ...but recycles what it can.\nassert(patchedDoc.h === doc.h);\n```\n\n## Alternatives\n\n- [`json-merge-patch`](https://github.com/pierreinglebert/json-merge-patch) (from which this library is forked)\n\n- [`merge-patch`](https://github.com/krisnye/merge-patch)\n\n- [`json8-merge-patch`](https://github.com/JSON8/merge-patch)\n\nAll are in-place.\nTo avoid mutations of the original object, one can deep-clone beforehand, but it can be expensive.\nAt the contrary, `tiny-merge-patch` does not alter any of its arguments—but\nrecycles what it can.\nRecycling also allows efficient strict identity-based memoization\n(used by [React](https://reactjs.org)'s [PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent) for example).\n\nAll of the above libraries also embed additional functionalities, such as patch generation from two objects or merge of patches.\n`tiny-merge-patch` only focuses on the IETF standard and on patch applications.\n\n(None of the above libraries are particularly big.\nStill, `tiny-merge-patch` is smaller if you only need to apply patches.\nIt is also worth mentioning that unlike\n[JSON patches](https://tools.ietf.org/html/rfc6902), there is no way to\nimplement merge of merge patches that reliably preserves deletion.)\n\n- [`immutable-merge-patch`](https://www.npmjs.com/package/immutable-merge-patch): JSON merge patch implementation for [Immutable.js](https://facebook.github.io/immutable-js/).\n\n# License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentinroy%2Ftiny-merge-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquentinroy%2Ftiny-merge-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquentinroy%2Ftiny-merge-patch/lists"}