cspell-trie-lib 9.6.3 → 9.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +78 -26
  2. package/dist/index.js +3644 -3589
  3. package/package.json +6 -6
package/dist/index.d.ts CHANGED
@@ -606,31 +606,6 @@ declare const CASE_INSENSITIVE_PREFIX = "~";
606
606
  declare const FORBID_PREFIX = "!";
607
607
  declare const defaultTrieInfo: TrieInfo;
608
608
  //#endregion
609
- //#region src/lib/decodeTrie.d.ts
610
- declare function decodeTrie(raw: string | ArrayBufferView<ArrayBuffer> | Uint8Array<ArrayBuffer>): ITrie;
611
- //#endregion
612
- //#region src/lib/io/importExport.d.ts
613
- interface ExportOptions {
614
- base?: number;
615
- comment?: string;
616
- version?: number;
617
- addLineBreaksToImproveDiffs?: boolean;
618
- }
619
- /**
620
- * Serialize a TrieNode.
621
- * Note: This is destructive. The node will no longer be usable.
622
- * Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory.
623
- * Considering this is the last step before exporting, it was decided to let this be destructive.
624
- */
625
- declare function serializeTrie(root: TrieRoot, options?: ExportOptions | number): Iterable<string>;
626
- declare function importTrie(input: Iterable<string> | IterableIterator<string> | string[] | string): TrieRoot;
627
- //#endregion
628
- //#region src/lib/models/DictionaryInformation.d.ts
629
- type DictionaryInformation = Exclude<DictionaryDefinitionAugmented["dictionaryInformation"], undefined>;
630
- //#endregion
631
- //#region src/lib/mappers/mapDictionaryInfoToWeightMap.d.ts
632
- declare function mapDictionaryInformationToWeightMap(dictInfo: DictionaryInformation): WeightMap;
633
- //#endregion
634
609
  //#region ../cspell-pipe/dist/operators/types.d.ts
635
610
  type OperatorSync<T, U = T> = (i: Iterable<T>) => Iterable<U>;
636
611
  //#endregion
@@ -842,7 +817,84 @@ declare function parseDictionaryLines(lines: Iterable<string> | string, options?
842
817
  declare function parseDictionaryLegacy(text: string | string[], options?: Partial<ParseDictionaryOptions>): Trie;
843
818
  declare function parseDictionary(text: string | Iterable<string>, options?: Partial<ParseDictionaryOptions>): ITrie;
844
819
  //#endregion
820
+ //#region src/lib/decodeTrie.d.ts
821
+ declare function decodeTrie(raw: string | ArrayBufferView<ArrayBuffer> | Uint8Array<ArrayBuffer>): ITrie;
822
+ interface FileResource {
823
+ /**
824
+ * The URL of the File
825
+ */
826
+ readonly url: URL;
827
+ /**
828
+ * The contents of the file
829
+ */
830
+ readonly content: string | Uint8Array<ArrayBuffer>;
831
+ }
832
+ declare function decodeFile(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<ITrie>;
833
+ declare function convertToBTrie(file: FileResource, options?: Partial<ParseDictionaryOptions>): Promise<FileResource>;
834
+ //#endregion
835
+ //#region src/lib/GTrie/GTrie.d.ts
836
+ declare class GTrieNode<K, V> {
837
+ children: Map<K, GTrieNode<K, V>> | undefined;
838
+ value: V | undefined;
839
+ constructor(value?: V, children?: Map<K, GTrieNode<K, V>>);
840
+ }
841
+ /**
842
+ * ### Generic Tries
843
+ *
844
+ * This is a Trie class that can contain any data. It is used in optimizing the dictionary and storing lookup data.
845
+ * The performance is "good enough" for most uses, but may need to be optimized for large data sets.
846
+ *
847
+ * K - Key type
848
+ * V - Value type
849
+ */
850
+ declare class GTrie<K, V> {
851
+ root: GTrieNode<K, V>;
852
+ constructor();
853
+ /**
854
+ *
855
+ * @param keys - the path to the child node
856
+ * @param value - the value to set / insert
857
+ * @return the previous value if one existed
858
+ */
859
+ insert(keys: Iterable<K>, value: V): V | undefined;
860
+ /**
861
+ * Insert nodes for the given keys into the trie.
862
+ * Existing nodes are reused.
863
+ * @param keys
864
+ * @returns the final node inserted or found
865
+ */
866
+ insertNode(keys: Iterable<K>): GTrieNode<K, V>;
867
+ findNode(keys: Iterable<K>): GTrieNode<K, V> | undefined;
868
+ has(keys: Iterable<K>): boolean;
869
+ hasNode(keys: Iterable<K>): boolean;
870
+ get(keys: Iterable<K>): V | undefined;
871
+ static fromEntries<K, V>(entries: Iterable<[Iterable<K>, V]>): GTrie<K, V>;
872
+ }
873
+ //#endregion
874
+ //#region src/lib/io/importExport.d.ts
875
+ interface ExportOptions {
876
+ base?: number;
877
+ comment?: string;
878
+ version?: number;
879
+ addLineBreaksToImproveDiffs?: boolean;
880
+ }
881
+ /**
882
+ * Serialize a TrieNode.
883
+ * Note: This is destructive. The node will no longer be usable.
884
+ * Even though it is possible to preserve the trie, dealing with very large tries can consume a lot of memory.
885
+ * Considering this is the last step before exporting, it was decided to let this be destructive.
886
+ */
887
+ declare function serializeTrie(root: TrieRoot, options?: ExportOptions | number): Iterable<string>;
888
+ declare function importTrie(input: Iterable<string> | IterableIterator<string> | string[] | string): TrieRoot;
889
+ //#endregion
890
+ //#region src/lib/models/DictionaryInformation.d.ts
891
+ type DictionaryInformation = Exclude<DictionaryDefinitionAugmented["dictionaryInformation"], undefined>;
892
+ //#endregion
893
+ //#region src/lib/mappers/mapDictionaryInfoToWeightMap.d.ts
894
+ declare function mapDictionaryInformationToWeightMap(dictInfo: DictionaryInformation): WeightMap;
895
+ //#endregion
845
896
  //#region src/lib/TrieBlob/trieDataEncoder.d.ts
897
+ declare function encodeITrieToBTrie(trie: ITrie, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
846
898
  declare function encodeTrieDataToBTrie(data: TrieData, buildOptions?: BuildOptions): Uint8Array<ArrayBuffer>;
847
899
  //#endregion
848
900
  //#region src/lib/TrieBuilder.d.ts
@@ -963,5 +1015,5 @@ declare const normalizeWordForCaseInsensitive: (text: string) => string[];
963
1015
  */
964
1016
  declare function expandCharacterSet(line: string, rangeChar?: string): Set<string>;
965
1017
  //#endregion
966
- export { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, ChildMap, CompoundWordsMethod, ExportOptions, FLAG_WORD, FORBID_PREFIX, FindFullResult, FindWordOptions, HintedWalkerIterator, Hinting, ITrie, JOIN_SEPARATOR, MaxCost, OPTIONAL_COMPOUND_FIX, type PartialTrieOptions, SuggestionCollector, type SuggestionCostMapDef, SuggestionResult, Trie, TrieBuilder, TrieNode, type TrieOptions, type TrieOptionsRO, TrieRoot, WORD_SEPARATOR, WalkerIterator, WeightMap, YieldResult, buildITrieFromWords, buildTrie, buildTrieFast, consolidate, countNodes, countWords, createDictionaryLineParserMapper as createDictionaryLineParser, createTrieRoot, createTrieRootFromList, createWeightedMap, decodeTrie, defaultTrieInfo, defaultTrieInfo as defaultTrieOptions, editDistance, editDistanceWeighted, encodeTrieDataToBTrie, expandCharacterSet, findNode, has, hintedWalker, impersonateCollector, importTrie, insert, isCircular, isDefined, isWordTerminationNode, iterateTrie, iteratorTrieWords, mapDictionaryInformationToWeightMap, mergeDefaults, mergeOptionalWithDefaults, normalizeWord, normalizeWordForCaseInsensitive, normalizeWordToLowercase, orderTrie, parseDictionary, parseDictionaryLegacy, parseDictionaryLines, serializeTrie, suggestionCollector, trieNodeToRoot, walk, walker };
1018
+ export { CASE_INSENSITIVE_PREFIX, COMPOUND_FIX, ChildMap, CompoundWordsMethod, ExportOptions, FLAG_WORD, FORBID_PREFIX, FindFullResult, FindWordOptions, GTrie, GTrieNode, HintedWalkerIterator, Hinting, ITrie, JOIN_SEPARATOR, MaxCost, OPTIONAL_COMPOUND_FIX, type PartialTrieOptions, SuggestionCollector, type SuggestionCostMapDef, SuggestionResult, Trie, TrieBuilder, TrieNode, type TrieOptions, type TrieOptionsRO, TrieRoot, WORD_SEPARATOR, WalkerIterator, WeightMap, YieldResult, buildITrieFromWords, buildTrie, buildTrieFast, consolidate, convertToBTrie, countNodes, countWords, createDictionaryLineParserMapper as createDictionaryLineParser, createTrieRoot, createTrieRootFromList, createWeightedMap, decodeFile, decodeTrie, defaultTrieInfo, defaultTrieInfo as defaultTrieOptions, editDistance, editDistanceWeighted, encodeITrieToBTrie, encodeTrieDataToBTrie, expandCharacterSet, findNode, has, hintedWalker, impersonateCollector, importTrie, insert, isCircular, isDefined, isWordTerminationNode, iterateTrie, iteratorTrieWords, mapDictionaryInformationToWeightMap, mergeDefaults, mergeOptionalWithDefaults, normalizeWord, normalizeWordForCaseInsensitive, normalizeWordToLowercase, orderTrie, parseDictionary, parseDictionaryLegacy, parseDictionaryLines, serializeTrie, suggestionCollector, trieNodeToRoot, walk, walker };
967
1019
  //# sourceMappingURL=index.d.ts.map