mendoza-js

Mendoza decoder in TypeScript.
Installation
$ npm install mendoza
// or
$ yarn add mendoza
Usage
Basic example:
import {applyPatch} from "mendoza"
let left = {…};
let patch = […];
let right = applyPatch(left, patch);
Incremental patcher:
import {incremental} from "mendoza"
const {Value, rebaseValue, wrap, unwrap, getType, applyPatch} = incremental
const ROOT = wrap(null, null);
let patches = […];
let origin = 0;
let value = ROOT;
let rebaseTarget;
for (let patch of patches) {
let newValue = applyPatch(value, patch, origin);
if (rebaseTarget) {
newValue = rebaseValue(rebaseTarget, newValue);
}
if (getType(newValue) === "null") {
rebaseTarget = value;
} else {
rebaseTarget = null;
}
value = newValue;
origin++;
}
console.log(unwrap(value));
License
MIT © Sanity.io
Release new version
Run the "CI & Release" workflow.
Make sure to select the main branch and check "Release new version".
Semantic release will only release on configured branches, so it is safe to run release on any branch.