/** * Trie file format v4 * * Trie format v4 is very similar to v3. The v4 reader can even read v3 files. * The motivation behind v4 is to reduce the cost of storing `.trie` files in git. * When a word is added in v3, nearly the entire file is changed due to the absolute * references. V4 adds an index sorted by the most frequently used reference to the least. * Because git diff is line based, it is important to add line breaks at logical points. * V3 added line breaks just to make sure the lines were not too long, V4 takes a different * approach. Line breaks are added at two distinct points. First, at the start of each two * letter prefix and second after approximately 50 words have been emitted. * * To improve readability and git diff, at the beginning of each two letter prefix, * a comment is emitted. * * Example: * * ``` * /* ab *​/ * ``` */ import { Sequence } from 'gensequence'; import { TrieNode, TrieRoot } from '../TrieNode'; export declare const DATA = "__DATA__"; export interface ExportOptions { base?: number; comment?: string; /** * This will reduce the size of the `.trie` file by removing references to short suffixes. * But it does increase the size of the trie when loaded into memory. */ optimizeSimpleReferences?: boolean; } /** * Serialize a TrieRoot. */ export declare function serializeTrie(root: TrieRoot, options?: ExportOptions | number): Sequence; interface ReferenceMap { /** * An array of references to nodes. * The most frequently referenced is first in the list. * A node must be reference by other nodes to be included. */ refCounts: (readonly [TrieNode, number])[]; } declare function buildReferenceMap(root: TrieRoot, base: number): ReferenceMap; export declare function importTrie(linesX: Iterable | string): TrieRoot; export declare const __testing__: { buildReferenceMap: typeof buildReferenceMap; }; export {}; //# sourceMappingURL=importExportV4.d.ts.map