encode-shared.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * A node inside the encoding trie used by `encode.ts`.
  3. *
  4. * There are two physical shapes to minimize allocations and lookup cost:
  5. *
  6. * 1. Leaf node (string)
  7. * - A plain string (already in the form `"&name;"`).
  8. * - Represents a terminal match with no children.
  9. *
  10. * 2. Branch / value node (object)
  11. */
  12. export type EncodeTrieNode = string | {
  13. /**
  14. * Entity value for the current code point sequence (wrapped: `&...;`).
  15. * Present when the path to this node itself is a valid named entity.
  16. */
  17. value: string | undefined;
  18. /** If a number, the next code unit of the only next character. */
  19. next: number | Map<number, EncodeTrieNode>;
  20. /** If next is a number, `nextValue` contains the entity value. */
  21. nextValue?: string;
  22. };
  23. /**
  24. * Parse a compact encode trie string into a Map structure used for encoding.
  25. *
  26. * Format per entry (ascending code points using delta encoding):
  27. * <diffBase36>[&name;][{<children>}] -- diff omitted when 0
  28. * Where diff = currentKey - previousKey - 1 (first entry stores absolute key).
  29. * `&name;` is the entity value (already wrapped); a following `{` denotes children.
  30. */
  31. export declare function parseEncodeTrie(serialized: string): Map<number, EncodeTrieNode>;
  32. //# sourceMappingURL=encode-shared.d.ts.map