3.0.7 • Published 8 days ago
mendoza v3.0.7
mendoza-js
Mendoza decoder in TypeScript.
Installation
npm install mendoza
or
pnpm 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
// Create an empty initial version:
const ROOT = wrap(null, null);
// Input of patches:
let patches = […];
// `origin` can be whatever you want to identify where a change comes from:
let origin = 0;
// Reference to the latest version:
let value = ROOT;
// Rebasing is for maintaing history across deleted versions:
let rebaseTarget;
for (let patch of patches) {
// Apply the patch:
let newValue = applyPatch(value, patch, origin);
// Rebase if needed:
if (rebaseTarget) {
newValue = rebaseValue(rebaseTarget, newValue);
}
// If the document was deleted, store the previous version so we can rebase:
if (getType(newValue) === "null") {
rebaseTarget = value;
} else {
rebaseTarget = null;
}
value = newValue;
origin++;
}
// Return the final full object:
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.
3.0.7
8 days ago
3.0.6
1 month ago
3.0.5
2 months ago
3.0.4
3 months ago
2.1.2
9 months ago
3.0.1-canary.6
9 months ago
3.0.3
9 months ago
3.0.1-canary.5
9 months ago
3.0.2
9 months ago
3.0.1
9 months ago
3.0.1-canary.7
9 months ago
3.0.1-canary.2
9 months ago
3.0.1-canary.1
9 months ago
3.0.1-canary.4
9 months ago
3.0.1-canary.3
9 months ago
3.0.0
9 months ago
3.0.3-canary.0
9 months ago
3.0.1-canary.0
9 months ago
2.1.1
3 years ago
2.1.0
3 years ago
2.0.10-canary.0
3 years ago
2.0.9
3 years ago
1.150.9-review-changes.1024
4 years ago
2.0.1
4 years ago
1.150.9-review-changes.952
4 years ago
1.150.9-review-changes.912
4 years ago
1.150.9-review-changes.877
4 years ago
1.150.9-review-changes.736
4 years ago
1.150.8-review-changes.644
4 years ago
1.150.8-review-changes.463
4 years ago
1.150.8-review-changes.382
4 years ago
1.150.8-review-changes.379
4 years ago
1.150.8-review-changes.375
4 years ago