IR utilities: validation, diffing, patching, migration
npm install @glyphjs/irIR (Intermediate Representation) utilities for Glyph JS: validation, diffing, patching, and migration.
``bash`
pnpm add @glyphjs/ir
`ts
import { validateIR, diffIR, applyPatch, createEmptyIR } from '@glyphjs/ir';
// Create a blank document
const doc = createEmptyIR();
// Validate an IR document
const diagnostics = validateIR(doc);
// Diff two IR documents
const patch = diffIR(oldDoc, newDoc);
// Apply a patch
const updated = applyPatch(oldDoc, patch);
`
- validateIR(ir) -- validate an IR document and return diagnosticsdiffIR(a, b)
- -- compute a patch that transforms a into bapplyPatch(ir, patch)
- -- apply a patch to an IR documentcomposePatch(a, b)
- -- compose two patches into oneregisterMigration(migration)
- / migrateIR(ir) -- version migration supportgenerateBlockId()
- / generateDocumentId() -- deterministic ID generationcreateEmptyIR()` -- factory for a blank IR document
-
https://github.com/VledicFranco/glyphjs