Skip to content

Type Editor


Type Editor / @type-editor/changeset / tokenizer/tokenize-fragment / tokenizeFragment

Function: tokenizeFragment()

ts
function tokenizeFragment<T>(fragment, encoder, start, end, target): T[];

Defined in: tokenizer/tokenize-fragment.ts:19

Convert the given range of a fragment to tokens for diff comparison. Recursively processes the fragment tree, encoding text characters and node boundaries.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDescription
fragmentFragmentThe fragment to tokenize.
encoderTokenEncoder<T>The encoder to use for converting nodes and characters to tokens.
startnumberThe start offset within the fragment.
endnumberThe end offset within the fragment.
targetT[]The array to append tokens to.

Returns

T[]

The target array with all tokens appended.