### Install zen-json-patch Library Source: https://github.com/sylphxltd/zen-json-patch/blob/main/README.md Instructions for installing the zen-json-patch library using popular package managers like npm, yarn, and pnpm. This step is required before using the library in your project. ```bash npm install zen-json-patch # or yarn add zen-json-patch # or pnpm add zen-json-patch ``` -------------------------------- ### Generate JSON Patch Diff in TypeScript Source: https://github.com/sylphxltd/zen-json-patch/blob/main/README.md Demonstrates the basic usage of the `diff` function from 'zen-json-patch' to compute JSON Patch operations between two JavaScript objects. The example shows how to import the function, define input objects, call `diff`, and inspect the resulting operations, including add, remove, and replace. ```typescript import { diff } from 'zen-json-patch'; const obj1 = { a: 1, b: "hello" }; const obj2 = { a: 2, c: "world" }; const operations = diff(obj1, obj2); console.log(operations); // Expected output (order might vary slightly depending on internal details): // [ // { op: 'remove', path: '/b' }, // { op: 'replace', path: '/a', value: 2 }, // { op: 'add', path: '/c', value: 'world' } // ] ``` -------------------------------- ### Run Development Scripts for zen-json-patch Source: https://github.com/sylphxltd/zen-json-patch/blob/main/README.md Commands for developers to run tests, benchmarks, and build the zen-json-patch project. These scripts are essential for contributing to or maintaining the library. ```bash npm test npm run bench npm run build ``` -------------------------------- ### Empty JSON Placeholder for Guideline Checksums Source: https://github.com/sylphxltd/zen-json-patch/blob/main/memory-bank/techContext.md An empty JSON object placeholder, intended to be populated with Git Blob SHAs for relevant Playbook guidelines as they are verified and used. ```json {} ``` -------------------------------- ### JSON Patch Diff Function API Definition Source: https://github.com/sylphxltd/zen-json-patch/blob/main/memory-bank/systemPatterns.md Defines the primary function for generating JSON Patch operations between two JSON objects, ensuring strict compliance with RFC 6902. This function takes two objects and returns an array of operations required to transform the first object into the second. ```APIDOC diff(obj1: any, obj2: any): Operation[] obj1: The source JSON object. obj2: The target JSON object. Returns: An array of JSON Patch operations (RFC 6902 compliant). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.