Transform a document bit-by-bit: apply an optional PatchDocument
and/or per-bit preHook/postHook, then re-emit.
The patch document selects bits by pre-application index and/or id (or
"all") and patches, removes, moves or inserts them; a bare array of
entries is the shorthand for "patch every bit". Hooks always see the
original bits, in order, before the document reshapes anything, and a
hook's patches apply after the document's for that bit. diff with
outputFormat: "patch" produces a document that turns one version of a
file into another.
With neither hook, the whole document is transformed in a single WASM pass
(the fast path). When a preHook or postHook is supplied, transform
drives the bits one at a time on the calling thread — the hook inspects each
bit, may return patches / an output-format override / drop, and only data
crosses into WASM.
options.inputFormat defaults to "auto"; prefer an explicit format when
known — see convert.
Transform a document bit-by-bit: apply an optional PatchDocument and/or per-bit
preHook/postHook, then re-emit.The patch document selects bits by pre-application index and/or id (or
"all") and patches, removes, moves or inserts them; a bare array of entries is the shorthand for "patch every bit". Hooks always see the original bits, in order, before the document reshapes anything, and a hook's patches apply after the document's for that bit.diffwithoutputFormat: "patch"produces a document that turns one version of a file into another.With neither hook, the whole document is transformed in a single WASM pass (the fast path). When a
preHookorpostHookis supplied,transformdrives the bits one at a time on the calling thread — the hook inspects each bit, may return patches / an output-format override /drop, and only data crosses into WASM.options.inputFormatdefaults to"auto"; prefer an explicit format when known — see convert.