### JSON Pointer CLI Example Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pointer-test.md An example of running the json-pointer-test CLI with 'json-pointer' as the executable path, showing typical output including test results. ```bash json-pointer-test json-pointer Running JSON Pointer tests. ✅ Retrieves first level key from object ✅ Can find number root ✅ Can find string root ✅ Returns container object and key ✅ Can reference array element ✅ Throws "NOT_FOUND" on missing keys two levels deep ✅ Throws "INVALID_INDEX" when pointing past array boundary ✅ Throws "INVALID_INDEX" when pointing to negative element ✅ RFC6901 Section 5. "" ✅ RFC6901 Section 5. "/foo" ✅ RFC6901 Section 5. "/foo/0" ✅ RFC6901 Section 5. "/" ✅ RFC6901 Section 5. "/a~1b" ✅ RFC6901 Section 5. "/c%d" ✅ RFC6901 Section 5. "/e^f" ✅ RFC6901 Section 5. "/g|h" ✅ RFC6901 Section 5. "/i\j" ✅ RFC6901 Section 5. "/k"l" ✅ RFC6901 Section 5. "/ " ✅ RFC6901 Section 5. "/m~0n" Successful = 20, Failed = 0, Total = 20 Done in 0.80s. ``` -------------------------------- ### Install JSON Joy CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/README.md Installs the JSON Joy command-line interface globally using npm. This command makes the various JSON Joy CLI executables available in your system's PATH. ```bash npm i -g json-joy ``` -------------------------------- ### Install json-joy CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pack-test.md Installs the json-joy package globally using npm, which includes the json-pack-test CLI. ```bash npm install -g json-joy ``` -------------------------------- ### Install json-joy CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-unpack.md Installs the json-joy package globally using npm, making the json-unpack CLI available. ```bash npm install -g json-joy ``` -------------------------------- ### Install JSON Pointer CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pointer.md Installs the json-joy package globally using npm, making the json-pointer CLI executable available. ```bash npm install -g json-joy ``` -------------------------------- ### Install JSON Pack CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pack.md Installs the json-joy package globally using npm, making the json-pack CLI available on your system. ```bash npm install -g json-joy ``` -------------------------------- ### Install json-joy CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch.md Installs the json-joy package globally using npm, making the json-patch CLI available on your system. ```bash npm install -g json-joy ``` -------------------------------- ### Example Usage of json-pack-test CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pack-test.md Demonstrates how to use the json-pack-test CLI by providing 'json-pack' as the path to the json-pack executable. This command will run the test suite. ```bash json-pack-test json-pack ``` -------------------------------- ### Usage Example: JSON to MessagePack Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pack.md Demonstrates how to pipe a JSON string into the json-pack CLI to convert it into MessagePack format. The output is the binary MessagePack representation. ```bash echo '{"foo":"bar"}' | json-pack ``` -------------------------------- ### JSON Patch 'test' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Provides examples of the 'test' operation in JSON Patch, demonstrating how to validate primitive values, complex objects, and array elements, including error cases. ```javascript /* ✅ Correctly tests root primitive ✅ Correctly tests root complex object ✅ Correctly tests first level array ✅ Throws error on invalid deep comparison ✅ Throws error on invalid primitive comparison */ ``` -------------------------------- ### JSON Pointer CLI Usage Example Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pointer.md Demonstrates how to use the json-pointer CLI by piping a JSON string to it with a JSON Pointer argument. It shows the expected output for resolving '/foo'. ```bash echo '{"foo": "bar"}' | json-pointer /foo ``` ```json "bar" ``` -------------------------------- ### ot-string Encoding Example Source: https://github.com/streamich/json-joy/blob/master/src/json-ot/types/ot-string/README.md Illustrates the efficient binary encoding of an ot-string operation using MessagePack. Shows how different component types (integer, string, negative integer) are encoded. ```js [5, "hello", -4] ``` -------------------------------- ### Compact JSON Patch+ Operation Encoding Source: https://github.com/streamich/json-joy/blob/master/src/json-patch/codec/compact/README.md Demonstrates the compact array-based encoding for JSON Patch+ operations, contrasting it with the nominal JSON encoding. The `add` operation is shown as an example. ```json [0, ["foo", "bar"], 123] ``` ```json {"op": "add", "path": "/foo/bar", "value": 123} ``` -------------------------------- ### JSON Predicate: Starts Operation Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Describes the 'starts' predicate operation for string matching. It covers successful matches, case-insensitive matching, and error conditions for incorrect matches or case mismatches, applicable at the root, in objects, and in arrays. ```APIDOC JSON Predicate: Starts Operation - At root, succeeds when matches correctly a substring - At root, can ignore case - At root, can ignore case - 2 - At root, throws when case does not match - At root, throws when matches substring incorrectly - In object, succeeds when matches correctly a substring - In object, throws when matches substring incorrectly - In array, succeeds when matches correctly a substring - In array, throws when matches substring incorrectly ``` -------------------------------- ### Usage of Compact Codec for JSON Patch+ Source: https://github.com/streamich/json-joy/blob/master/src/json-patch/codec/compact/README.md Provides a TypeScript example of how to use the `compact` codec to encode and decode JSON Patch+ operations. It imports necessary components and demonstrates the encode/decode functions. ```ts import {OpTest, OpReplace} from 'json-joy/{lib,es6,ems}/json-patch'; import {encode, decode} from 'json-joy/{lib,es6,ems}/json-patch/codec/compact'; const patch = [new OpTest('/foo', 'bar'), new OpReplace('/foo', 'baz')]; const encoded = encode(patch); const decoded = decode(encoded); ``` -------------------------------- ### JSON Patch 'replace' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md This section illustrates the functionality of the JSON Patch 'replace' operation. It includes examples of replacing non-existing keys, replacing the root document with various data types (null, boolean, integer, string, object, array), and replacing existing values. ```json-patch JSON Patch "replace" operation ✅ Replacing non-existing object key, first level ✅ Replace root "null" by "null" ✅ Replace root "null" by "false" ✅ Replace root "null" by integer ✅ Replace root "null" by string ✅ Replace root "null" by simple object ✅ Replace root "null" by simple array ✅ Replace root "false" by "null" ✅ Replace root "false" by "false" ✅ Replace root "false" by integer ✅ Replace root "false" by string ✅ Replace root "false" by simple object ✅ Replace root "false" by simple array ✅ Replace root integer by "null" ✅ Replace root integer by "false" ✅ Replace root integer by integer ✅ Replace root integer by string ✅ Replace root integer by simple object ``` -------------------------------- ### ot-string Operation Example Source: https://github.com/streamich/json-joy/blob/master/src/json-ot/types/ot-string/README.md Demonstrates the structure of an ot-string operation, which is a JSON array of components. Components can be retain (positive integer), insert (string), or delete (negative integer or a string in a one-element array). ```js [5, 'inserted', -1, 3, ['deleted']]; ``` -------------------------------- ### JSON Patch for Slate.js 'split' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Details the 'split' operation for Slate.js documents within JSON Patch, covering splitting text nodes, element nodes, handling attributes, and various positioning scenarios. ```javascript /* ✅ Slate.js, split a single "ab" paragraphs into two ✅ Slate.js, split two element blocks into one ✅ Slate.js, can split paragraph in two and insert a character ✅ At root, string, can split string in two ✅ At root, string, can split string in two at pos=1 ✅ At root, string, can split string in two from beginning ✅ At root, string, can split string in two from end ✅ At root, string, can split string in two when pos is greater than string length ✅ At root, string, takes characters from end if pos is negative ✅ At root, string, takes characters from end if pos is negative - 2 ✅ At root, string, when negative pos overflows, first element is empty ✅ At root, SlateTextNode, splits simple SlateTextNode ✅ At root, SlateTextNode, preserves text node attributes ✅ At root, SlateTextNode, can add custom attributes ✅ At root, SlateTextNode, custom attributes can overwrite node attributes ✅ At root, SlateElementNode, splits simple node ✅ At root, SlateElementNode, can provide custom attributes ✅ At root, SlateElementNode, carries over node attributes ✅ At root, SlateElementNode, can overwrite node attributes ✅ In object, can split string in two ✅ In object, if attribute are specified, wraps strings into nodes */ ``` -------------------------------- ### JSON Patch 'move' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Illustrates the 'move' operation in JSON Patch, covering copying values within objects, between objects and arrays, and across different array positions. ```javascript /* ✅ Can copy value to key of the same object ✅ Can overwrite object key of the same object ✅ Can copy value from parent object to child array ✅ Can copy value from child object to adjacent child array ✅ Can copy value from deep object to adjacent child array ✅ Can copy value from array into object ✅ Can copy values between two arrays ✅ Can copy value and return it back */ ``` -------------------------------- ### JSON Patch 'copy' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Showcases the 'copy' operation in JSON Patch, detailing how to duplicate values between keys in the same object, across objects and arrays, and within arrays. ```javascript /* ✅ Can move values between keys of the same object ✅ Can overwrite object key of the same object ✅ Can move value from parent object to child array ✅ Can move value from child object to adjacent child array ✅ Can move value from deep object to adjacent child array ✅ Can move value from array into object ✅ Can move values between two arrays ✅ Can move value and return it back */ ``` -------------------------------- ### JSON Patch 'add' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md This section demonstrates various use cases for the JSON Patch 'add' operation. It covers adding to the root document, setting object keys with different data types, inserting into arrays at various positions, and handling errors for invalid insertions. ```json-patch JSON Patch "add" operation ✅ Can set root document ✅ Can set empty object key to string ✅ Can set empty object key to object ✅ Can update existing key ✅ Can insert into first level empty array using index "0" ✅ Can insert into first level empty array using index "-" ✅ Throws error when inserting into empty first level array at index "1" ✅ Can insert into second level empty array using index "0" ✅ Can insert into first level empty array using index "-" ✅ Throws error when inserting into empty first level array at index "1" ✅ Can execute multiple updates in a row ``` -------------------------------- ### Execute All Tests Source: https://github.com/streamich/json-joy/blob/master/src/__tests__/README.md Builds the project and then runs all defined tests. This is the primary command for ensuring the entire project passes its test suite. ```bash yarn build yarn test:all ``` -------------------------------- ### JSON View Example Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt/codec/sidecar/README.md A sample JSON document representing a view. ```json { "a": { "b": { "d": "foo", "c": [1, 2, 3] } } } ``` -------------------------------- ### Execute End-to-End CLI Tests Source: https://github.com/streamich/json-joy/blob/master/src/__tests__/README.md Builds the project and then executes all end-to-end tests related to the Command Line Interface (CLI). ```bash yarn build yarn test:cli ``` -------------------------------- ### View Node References (Skipping Objects) Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt/codec/sidecar/README.md Examples of referencing elements in a JSON view using paths that skip intermediate objects. ```javascript 0: ['a'] // Key at root field "a" 1: ['a', 'b'] // Key at root field "a", field "b" 2: ['a', 'b', 'c'] // Key at root field "a", field "b", field "c" 3: ['a', 'b', 'c', value, 0] // Element at root field "a", field "b", field "c", index 0 4: ['a', 'b', 'c', value, 1] // Element at root field "a", field "b", field "c", index 1 5: ['a', 'b', 'c', value, 2] // Element at root field "a", field "b", field "c", index 2 6: ['a', 'b', 'd'] // Key at root field "a", field "b", field "d" ``` -------------------------------- ### Binary Codec Usage Source: https://github.com/streamich/json-joy/blob/master/src/json-patch/codec/binary/README.md Demonstrates how to use the `Encoder` and `Decoder` from the `binary` codec to encode and decode JSON Patch+ operations. It shows the import of necessary classes and the process of encoding a patch array into binary and then decoding it back. ```ts import {OpTest, OpReplace} from 'json-joy/{lib,es6,ems}/json-patch'; import {Encoder, Decoder} from 'json-joy/{lib,es6,ems}/json-patch/codec/binary'; const encoder = new Encoder(); const decoder = new Decoder(); const patch = [new OpTest('/foo', 'bar'), new OpReplace('/foo', 'baz')]; const encoded = encoder.encode(patch); const decoded = decoder.decode(encoded); ``` -------------------------------- ### Run JSON Stable Benchmarks Source: https://github.com/streamich/json-joy/blob/master/src/json-stable/README.md This command executes the benchmark script for json-joy's json-stable library. It compares its performance against JSON.stringify() and other stable stringification libraries for various data structures and sizes. ```shell node benchmarks/json-stable/bench.js ``` -------------------------------- ### View Node References (Full Paths) Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt/codec/sidecar/README.md Examples of referencing elements in a JSON view using full paths, including keys and array indices. ```javascript 0: [] // Whole document 1: ['a'] // Key at root field "a" 2: ['a', value] // Object at root field "a" 3: ['a', 'b'] // Key at root field "a", field "b" 4: ['a', 'b', value] // Object at root field "a", field "b" 5: ['a', 'b', 'c'] // Key at root field "a", field "b", field "c" 6: ['a', 'b', 'c', value] // Array at root field "a", field "b", field "c" 7: ['a', 'b', 'c', value, 0] // Element at root field "a", field "b", field "c", index 0 8: ['a', 'b', 'c', value, 1] // Element at root field "a", field "b", field "c", index 1 9: ['a', 'b', 'c', value, 2] // Element at root field "a", field "b", field "c", index 2 10: ['a', 'b', 'd'] // Key at root field "a", field "b", field "d" 11: ['a', 'b', 'd', value] // String at root field "a", field "b", field "d" ``` -------------------------------- ### Execute Unit Tests Source: https://github.com/streamich/json-joy/blob/master/src/__tests__/README.md Runs only the unit tests for the project. This is useful for quickly verifying individual components without the overhead of end-to-end tests. ```bash yarn test ``` -------------------------------- ### Run json-pack-test CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pack-test.md Executes the json-pack-test CLI, which requires the path to the json-pack executable as an argument. This initiates a test suite run against the provided executable. ```bash json-pack-test ``` -------------------------------- ### json-joy API Reference Source: https://github.com/streamich/json-joy/blob/master/README.md Provides access to the API reference documentation for the json-joy library, covering its various functionalities and specifications. ```APIDOC json-joy API Reference: - Website: https://jsonjoy.com - Documentation: https://jsonjoy.com/libs/json-joy-js - Blog posts: - Collaborative Text Editors (Part 2): Plain Text Synchronization - Collaborative Text Editors (Part 1): Prelude - Fuzz Testing RGA CRDT - Benchmarking JSON Serialization Codecs - List CRDT Benchmarks - Blazing Fast List CRDT Algorithm - Specifications: - JSON CRDT specification - JSON CRDT Patch specification - JSON Expression specification - JSON Reactive RPC specification - Compact JSON encoding - Test coverage: https://streamich.github.io/json-joy/coverage/lcov-report/ ``` -------------------------------- ### JSON Patch CLI Test Usage Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Demonstrates how to use the `json-patch-test` CLI tool. It requires the path to the `json-patch` executable as an argument to run the test suite. ```bash json-patch-test ``` -------------------------------- ### JSON Pointer CLI Usage Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-pointer-test.md Demonstrates how to use the json-pointer-test CLI. It requires a single argument: the path to the json-pointer executable to be tested. ```bash json-pointer-test ``` -------------------------------- ### json-joy Notable Features Source: https://github.com/streamich/json-joy/blob/master/README.md Highlights the key features and performance advantages of the json-joy library, emphasizing its speed and comprehensive JSON handling capabilities. ```javascript // Full JSON implementation as a CRDT (Conflict-free Replicated Datatype). // The fastest list CRDT implementation in JavaScript. // The fastest text OT (Operational Transformation) implementation in JavaScript. // The fastest implementation of CBOR, DAG-CBOR, MessagePack, UBJSON, and JSON codecs in JavaScript. // The fastest (HTTP) router implementation in JavaScript. // The fastest JSON schema validation implementation in JavaScript. // Very fast binary tree (Radix, AVL, Red-black, Splay) implementations in JavaScript. // Very fast JSON Patch (and JSON Pointer) implementation in JavaScript, including many non-standard operations, and JSON Predicate implementation. // Very fast JSON Expression implementation in JavaScript. ``` -------------------------------- ### JSON Patch 'remove' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Demonstrates various scenarios for removing array elements using the JSON Patch 'remove' operation, including nested arrays and boundary conditions. ```javascript /* ✅ Can remove array element at third level ✅ Can remove array element in first position ✅ Can remove array element in second position ✅ Can remove array element in third position ✅ Can remove array element in fourth position ✅ Can remove array element in fifth position ✅ Throws error when removing array element out of bounds ✅ Throws error when removing array element at negative index "-2" ✅ Throws error when removing array element at string index "str" */ ``` -------------------------------- ### Execute Specific CLI Test Suites Source: https://github.com/streamich/json-joy/blob/master/src/__tests__/README.md Runs individual end-to-end CLI test suites. This allows for targeted testing of specific CLI functionalities like pointer, patch, or pack. ```bash yarn test:cli:pointer ``` ```bash yarn test:cli:patch ``` ```bash yarn test:cli:pack ``` -------------------------------- ### JSON Patch Extended 'str_del' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Explains the extended 'str_del' operation for string deletion in JSON Patch, covering character removal by position and value, at root, within objects, and arrays. ```javascript /* ✅ At root, can remove characters ✅ At root, can remove characters by value ✅ At root, length can be arbitrary long ✅ At root, pos=1 leaves only first character ✅ In object, can remove last character ✅ In object, can remove middle character ✅ In object, can remove middle character by value ✅ In object, can remove first character ✅ In array, can remove last character ✅ In array, can remove middle character ✅ In array, can remove first character */ ``` -------------------------------- ### Block Elements in json-joy Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt-extensions/peritext/block/README.md Describes various block elements that form the structure of a rich-text document. These elements consume full width and can be nested. Examples include list items, blockquotes, tables, and headings. ```APIDOC Block Elements: - List items (bullet, ordered, todo) - Blockquote - Caption - Aside - Details + Summary (Toggle block) - section - hgroup - footer - table - caption - Callout - Bookmark - Paragraph - Heading - Code block - Definition list - Table of contents - Void elements (Line break, object) ``` -------------------------------- ### Peritext DOM Controller Initialization Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt-peritext-ui/README.md Illustrates the initialization of the `DomController` for handling DOM events within the Peritext UI. It takes `PeritextEventDefaults` as an argument. ```javascript import { DomController } from 'json-joy/lib/peritext/dom'; // Assuming 'defaults' is an instance of PeritextEventDefaults const controller = new DomController(defaults); // The controller is now ready to be used with Peritext components. ``` -------------------------------- ### JSON Patch Extended 'inc' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Illustrates the extended 'inc' operation for incrementing numeric values in JSON Patch, including arbitrary increment/decrement values, floating-point numbers, and type casting from strings. ```javascript /* ✅ Casts values and them increments them ✅ Can use arbitrary increment value, and can decrement ✅ Increment can be a floating point number ✅ At root, increments from 0 to 5 ✅ At root, increments from -0 to 5 ✅ In object, increments from 0 to 5 ✅ In object, casts string to number ✅ In object, can increment twice ✅ In array, increments from 0 to -3 */ ``` -------------------------------- ### Peritext UI Rendering Surface Source: https://github.com/streamich/json-joy/blob/master/src/json-crdt-peritext-ui/README.md Demonstrates the React rendering surface for Peritext UI, utilizing a DomController for DOM event handling and managing the editor's state. ```javascript import React from 'react'; import { PeritextFragment } from 'json-joy/lib/peritext/react'; import { DomController } from 'json-joy/lib/peritext/dom'; // Assuming 'defaults' is defined elsewhere const controller = new DomController(defaults); function PeritextEditor() { return ( ); } ``` -------------------------------- ### Execute Specific File Unit Tests Source: https://github.com/streamich/json-joy/blob/master/src/__tests__/README.md Runs unit tests for a specific file. Replace `` with the actual file name (e.g., `json-documents.ts`). ```bash yarn test ``` -------------------------------- ### JSON Patch Extended 'str_ins' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Details the extended 'str_ins' operation for string insertion in JSON Patch, covering insertion into empty and existing strings, at various positions, and error handling for non-string targets. ```javascript /* ✅ Can add text to empty string at root ✅ Can add text to empty string in object on first level ✅ Returns error if target is not a string - 1 ✅ Returns error if target is not a string - 2 ✅ Returns error if target is not a string - 3 ✅ Returns error if target is not a string - 4 ✅ Returns error if target is not a string - 5 ✅ Can add text to empty string at position greater than host string length ✅ Can insert text into a string ✅ Can insert text at the end of the string ✅ Can insert text into a string at position greater than host string length ✅ Can add text to empty string in array ✅ Can add text to empty string at position greater than host string length in array ✅ Can insert text into a string in array ✅ Can insert text at the end of the string in array ✅ Can insert text into a string at position greater than host string length in array ✅ Can create new string key and add content to it (if pos = 0 and there was nothing before) ✅ Throws if new string is create at position other than 0 (pos != 0) */ ``` -------------------------------- ### JSON Patch Copy Operation to OT Patch Source: https://github.com/streamich/json-joy/blob/master/src/json-ot/types/ot-json/README.md Illustrates the transformation of a JSON Patch 'copy' operation into the OT patch format, detailing the use of 'pick' and 'drop' to replicate data. ```js { op: 'copy', from: ['foo', 'a', 'b'], path: ['foo', 'bar'] } { pick: [ {reg: 0, path: ['foo', 'a', 'b']}, ], drop: [ {reg: 0, path: ['foo', 'a', 'b']}, {reg: 0, path: ['foo', 'bar']}, ], } ``` -------------------------------- ### JSON Patch Extended 'flip' Operation Examples Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch-test.md Demonstrates the extended 'flip' operation in JSON Patch, showing how it casts and flips boolean values (true/false) and numeric values (truthy/zero) at different levels of the JSON structure. ```javascript /* ✅ Casts values and them flips them ✅ At root, flips true to false ✅ At root, flips false to true ✅ At root, flips truthy number to false ✅ At root, flips zero to true ✅ In object, flips true to false ✅ In object, flips false to true ✅ In array, flips true to false and back */ ``` -------------------------------- ### Combined OT Patch for Multiple Operations Source: https://github.com/streamich/json-joy/blob/master/src/json-ot/types/ot-json/README.md Demonstrates how multiple JSON Patch operations, including 'replace' and 'move', are combined into a single OT patch, showing the aggregated 'pick' and 'drop' lists. ```js [ {op: 'replace', path: ['a', 'title'], value: 'hello'}, {op: 'move', from: ['a'], path: ['b']}, ] { pick: [ {reg: -1, path: ['a', 'title']}, {reg: 0, path: ['a']}, ], drop: [ {value: 'hello', path: ['a', 'title']}, {reg: 0, path: ['b']}, ], } [ {op: 'move', from: ['a'], path: ['b']}, {op: 'replace', path: ['b', 'title'], value: 'hello'}, ] { pick: [ {reg: -1, path: ['a', 'title']}, {reg: 0, path: ['a']}, ], drop: [ {reg: 0, path: ['b']}, {value: 'hello', path: ['b', 'title']}, ], } ``` -------------------------------- ### ot-string apply() Benchmarks Source: https://github.com/streamich/json-joy/blob/master/src/json-ot/types/ot-string/README.md Compares the performance of the ot-string apply() function against other OT text implementations like ottypes and quilljs/delta. Highlights the speed of json-joy/json-ot ot-string-irreversible. ```benchmark node benchmarks/json-ot/ot-string.apply.js json-joy/json-ot ot-string x 1,854,289 ops/sec ±3.35% (64 runs sampled), 539 ns/op json-joy/json-ot ot-string (reversible) x 1,908,440 ops/sec ±2.64% (78 runs sampled), 524 ns/op json-joy/json-ot ot-string-irreversible x 2,570,753 ops/sec ±2.42% (55 runs sampled), 389 ns/op ottypes/ot-text x 1,019,892 ops/sec ±4.06% (72 runs sampled), 980 ns/op ottypes/ot-text-unicode x 967,073 ops/sec ±5.52% (66 runs sampled), 1034 ns/op quilljs/delta x 89,151 ops/sec ±2.37% (72 runs sampled), 11217 ns/op ``` -------------------------------- ### Unpack MessagePack to JSON Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-unpack.md Demonstrates how to pipe MessagePack encoded data to the json-unpack CLI to receive JSON output. This is a common pattern for data transformation. ```bash | json-unpack ``` ```bash echo '{"foo":"bar"}' | json-pack | json-unpack {"foo":"bar"} ``` -------------------------------- ### Apply JSON Patch via CLI Source: https://github.com/streamich/json-joy/blob/master/src/json-cli/docs/json-patch.md Demonstrates how to use the json-patch CLI. It pipes a JSON document to the command and provides the JSON Patch array as an argument. The output shows the modified JSON document. ```bash echo '{"foo":"bar"}' | json-patch '[{"op":"add","path":"/foo","value":"baz"}]' ``` ```json { "foo": "baz" } ```