cspell-dictionary 6.9.0 → 6.10.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 (43) hide show
  1. package/package.json +6 -5
  2. package/dist/SpellingDictionary/Dictionaries.d.ts +0 -9
  3. package/dist/SpellingDictionary/Dictionaries.js +0 -61
  4. package/dist/SpellingDictionary/SpellingDictionaryError.d.ts +0 -10
  5. package/dist/SpellingDictionary/SpellingDictionaryError.js +0 -18
  6. package/dist/util/Comparable.d.ts +0 -20
  7. package/dist/util/Comparable.js +0 -55
  8. package/dist/util/FreqCounter.d.ts +0 -16
  9. package/dist/util/FreqCounter.js +0 -52
  10. package/dist/util/Memorizer.d.ts +0 -65
  11. package/dist/util/Memorizer.js +0 -138
  12. package/dist/util/MinHeapQueue.d.ts +0 -23
  13. package/dist/util/MinHeapQueue.js +0 -97
  14. package/dist/util/PairingHeap.d.ts +0 -32
  15. package/dist/util/PairingHeap.js +0 -90
  16. package/dist/util/TextMap.d.ts +0 -15
  17. package/dist/util/TextMap.js +0 -62
  18. package/dist/util/TextRange.d.ts +0 -28
  19. package/dist/util/TextRange.js +0 -144
  20. package/dist/util/debugPerf.d.ts +0 -9
  21. package/dist/util/debugPerf.js +0 -22
  22. package/dist/util/errors.d.ts +0 -17
  23. package/dist/util/errors.js +0 -52
  24. package/dist/util/fileReader.d.ts +0 -4
  25. package/dist/util/fileReader.js +0 -21
  26. package/dist/util/iterableIteratorLib.d.ts +0 -4
  27. package/dist/util/iterableIteratorLib.js +0 -14
  28. package/dist/util/logger.d.ts +0 -33
  29. package/dist/util/logger.js +0 -46
  30. package/dist/util/memorizerWeak.d.ts +0 -6
  31. package/dist/util/memorizerWeak.js +0 -42
  32. package/dist/util/resolveFile.d.ts +0 -13
  33. package/dist/util/resolveFile.js +0 -127
  34. package/dist/util/search.d.ts +0 -6
  35. package/dist/util/search.js +0 -23
  36. package/dist/util/textRegex.d.ts +0 -1
  37. package/dist/util/textRegex.js +0 -2
  38. package/dist/util/timer.d.ts +0 -26
  39. package/dist/util/timer.js +0 -58
  40. package/dist/util/util.test copy.d.ts +0 -2
  41. package/dist/util/util.test copy.js +0 -17
  42. package/dist/util/wordSplitter.d.ts +0 -46
  43. package/dist/util/wordSplitter.js +0 -326
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-dictionary",
3
- "version": "6.9.0",
3
+ "version": "6.10.0",
4
4
  "description": "A spelling dictionary library useful for checking words and getting suggestions.",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -38,10 +38,11 @@
38
38
  "node": ">=14"
39
39
  },
40
40
  "dependencies": {
41
- "@cspell/cspell-pipe": "workspace:^",
42
- "@cspell/cspell-types": "workspace:^",
43
- "cspell-trie-lib": "workspace:^",
41
+ "@cspell/cspell-pipe": "^6.10.0",
42
+ "@cspell/cspell-types": "^6.10.0",
43
+ "cspell-trie-lib": "^6.10.0",
44
44
  "fast-equals": "^4.0.3",
45
45
  "gensequence": "^4.0.2"
46
- }
46
+ },
47
+ "gitHead": "244f2ff310aa64bdb41cf93e85ba9e9f35c2b937"
47
48
  }
@@ -1,9 +0,0 @@
1
- import { CSpellSettingsInternal, DictionaryDefinitionInternal } from '../Models/CSpellSettingsInternalDef';
2
- import { SpellingDictionary } from './SpellingDictionary';
3
- import { SpellingDictionaryCollection } from './SpellingDictionaryCollection';
4
- export declare function loadDictionaryDefs(defsToLoad: DictionaryDefinitionInternal[]): Promise<SpellingDictionary>[];
5
- export declare function loadDictionaryDefsSync(defsToLoad: DictionaryDefinitionInternal[]): SpellingDictionary[];
6
- export declare function refreshDictionaryCache(maxAge?: number): Promise<void>;
7
- export declare function getDictionaryInternal(settings: CSpellSettingsInternal): Promise<SpellingDictionaryCollection>;
8
- export declare function getDictionaryInternalSync(settings: CSpellSettingsInternal): SpellingDictionaryCollection;
9
- //# sourceMappingURL=Dictionaries.d.ts.map
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDictionaryInternalSync = exports.getDictionaryInternal = exports.refreshDictionaryCache = exports.loadDictionaryDefsSync = exports.loadDictionaryDefs = void 0;
4
- const DictionarySettings_1 = require("../Settings/DictionarySettings");
5
- const util_1 = require("../util/util");
6
- const createSpellingDictionary_1 = require("./createSpellingDictionary");
7
- const DictionaryLoader_1 = require("./DictionaryLoader");
8
- const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
9
- function loadDictionaryDefs(defsToLoad) {
10
- return defsToLoad.map(DictionaryLoader_1.loadDictionary);
11
- }
12
- exports.loadDictionaryDefs = loadDictionaryDefs;
13
- function loadDictionaryDefsSync(defsToLoad) {
14
- return defsToLoad.map(DictionaryLoader_1.loadDictionarySync);
15
- }
16
- exports.loadDictionaryDefsSync = loadDictionaryDefsSync;
17
- function refreshDictionaryCache(maxAge) {
18
- return (0, DictionaryLoader_1.refreshCacheEntries)(maxAge);
19
- }
20
- exports.refreshDictionaryCache = refreshDictionaryCache;
21
- const emptyWords = Object.freeze([]);
22
- async function getDictionaryInternal(settings) {
23
- const spellDictionaries = await Promise.all(loadDictionaryDefs((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings)));
24
- return _getDictionaryInternal(settings, spellDictionaries);
25
- }
26
- exports.getDictionaryInternal = getDictionaryInternal;
27
- function getDictionaryInternalSync(settings) {
28
- const spellDictionaries = loadDictionaryDefsSync((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings));
29
- return _getDictionaryInternal(settings, spellDictionaries);
30
- }
31
- exports.getDictionaryInternalSync = getDictionaryInternalSync;
32
- function _getDictionaryInternal(settings, spellDictionaries) {
33
- const { words = emptyWords, userWords = emptyWords, flagWords = emptyWords, ignoreWords = emptyWords } = settings;
34
- const settingsWordsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(words, '[words]', 'From Settings `words`', {
35
- caseSensitive: true,
36
- weightMap: undefined,
37
- });
38
- const settingsUserWordsDictionary = userWords.length
39
- ? (0, createSpellingDictionary_1.createSpellingDictionary)(userWords, '[userWords]', 'From Settings `userWords`', {
40
- caseSensitive: true,
41
- weightMap: undefined,
42
- })
43
- : undefined;
44
- const ignoreWordsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(ignoreWords, '[ignoreWords]', 'From Settings `ignoreWords`', {
45
- caseSensitive: true,
46
- noSuggest: true,
47
- weightMap: undefined,
48
- });
49
- const flagWordsDictionary = (0, createSpellingDictionary_1.createForbiddenWordsDictionary)(flagWords, '[flagWords]', 'From Settings `flagWords`', {
50
- weightMap: undefined,
51
- });
52
- const dictionaries = [
53
- ...spellDictionaries,
54
- settingsWordsDictionary,
55
- settingsUserWordsDictionary,
56
- ignoreWordsDictionary,
57
- flagWordsDictionary,
58
- ].filter(util_1.isDefined);
59
- return (0, SpellingDictionaryCollection_1.createCollection)(dictionaries, 'dictionary collection');
60
- }
61
- //# sourceMappingURL=Dictionaries.js.map
@@ -1,10 +0,0 @@
1
- import { LoadOptions } from './DictionaryLoader';
2
- export declare class SpellingDictionaryLoadError extends Error {
3
- readonly uri: string;
4
- readonly options: LoadOptions;
5
- readonly cause: Error;
6
- readonly name: string;
7
- constructor(uri: string, options: LoadOptions, cause: Error, message: string);
8
- }
9
- export declare function isSpellingDictionaryLoadError(e: Error): e is SpellingDictionaryLoadError;
10
- //# sourceMappingURL=SpellingDictionaryError.d.ts.map
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSpellingDictionaryLoadError = exports.SpellingDictionaryLoadError = void 0;
4
- class SpellingDictionaryLoadError extends Error {
5
- constructor(uri, options, cause, message) {
6
- super(message);
7
- this.uri = uri;
8
- this.options = options;
9
- this.cause = cause;
10
- this.name = options.name;
11
- }
12
- }
13
- exports.SpellingDictionaryLoadError = SpellingDictionaryLoadError;
14
- function isSpellingDictionaryLoadError(e) {
15
- return e instanceof SpellingDictionaryLoadError;
16
- }
17
- exports.isSpellingDictionaryLoadError = isSpellingDictionaryLoadError;
18
- //# sourceMappingURL=SpellingDictionaryError.js.map
@@ -1,20 +0,0 @@
1
- export declare type Comparable = number | string | boolean | undefined | null | Date;
2
- export declare type ComparableFilter<T> = T extends Comparable ? T : never;
3
- export declare type ComparablePropertyNames<T> = {
4
- [K in keyof T]: T[K] extends Comparable ? K : never;
5
- }[keyof T];
6
- export declare type ComparableProperties<T> = Pick<T, ComparablePropertyNames<T>>;
7
- export declare type CompareArg<T> = ComparablePropertyNames<T> | ((t: T) => Comparable);
8
- export declare type CompareFn<T> = (a: T, b: T) => number;
9
- export declare function compareBy<T>(extract: CompareArg<T>, ...extractors: CompareArg<T>[]): CompareFn<T>;
10
- export declare function compareBy<T>(extract: CompareArg<T>): CompareFn<T>;
11
- export declare function compareBy<T>(extract1: CompareArg<T>, extract2: CompareArg<T>): CompareFn<T>;
12
- export declare function compareBy<T>(extract1: CompareArg<T>, extract2: CompareArg<T>, extract3: CompareArg<T>): CompareFn<T>;
13
- export declare function compareByRev<T>(extract: CompareArg<T>, ...extractors: CompareArg<T>[]): CompareFn<T>;
14
- export declare function compareByRev<T>(extract: CompareArg<T>): CompareFn<T>;
15
- export declare function compareByRev<T>(extract1: CompareArg<T>, extract2: CompareArg<T>): CompareFn<T>;
16
- export declare function compareByRev<T>(extract1: CompareArg<T>, extract2: CompareArg<T>, extract3: CompareArg<T>): CompareFn<T>;
17
- export declare function compareEach<T>(...compareFn: CompareFn<T>[]): CompareFn<T>;
18
- export declare function compare<T>(a: ComparableFilter<T>, b: ComparableFilter<T>): number;
19
- export declare function reverse<T>(fn: CompareFn<T>): CompareFn<T>;
20
- //# sourceMappingURL=Comparable.d.ts.map
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reverse = exports.compare = exports.compareEach = exports.compareByRev = exports.compareBy = void 0;
4
- function compareBy(extract, ...extractors) {
5
- const compareFns = [extract, ...extractors]
6
- .map((ex) => (typeof ex === 'function' ? ex : (t) => t[ex]))
7
- .map((ex) => (a, b) => _compare(ex(a), ex(b)));
8
- return compareEach(...compareFns);
9
- }
10
- exports.compareBy = compareBy;
11
- function compareByRev(extract, ...extractors) {
12
- return reverse(compareBy(extract, ...extractors));
13
- }
14
- exports.compareByRev = compareByRev;
15
- function compareEach(...compareFn) {
16
- return (a, b) => {
17
- for (const fn of compareFn) {
18
- const r = fn(a, b);
19
- if (r) {
20
- return r;
21
- }
22
- }
23
- return 0;
24
- };
25
- }
26
- exports.compareEach = compareEach;
27
- function _compare(a, b) {
28
- if (a === b)
29
- return 0;
30
- if (a === undefined)
31
- return 1;
32
- if (b === undefined)
33
- return -1;
34
- if (a === null)
35
- return 1;
36
- if (b === null)
37
- return -1;
38
- if (a < b)
39
- return -1;
40
- if (a > b)
41
- return 1;
42
- return 0;
43
- }
44
- function compare(a, b) {
45
- return _compare(a, b);
46
- }
47
- exports.compare = compare;
48
- function reverse(fn) {
49
- return (a, b) => {
50
- const r = fn(a, b);
51
- return r ? -r : 0;
52
- };
53
- }
54
- exports.reverse = reverse;
55
- //# sourceMappingURL=Comparable.js.map
@@ -1,16 +0,0 @@
1
- import { IterableLike } from './IterableLike';
2
- export declare class FreqCounter<T> {
3
- private _total;
4
- readonly _counters: Map<T, number>;
5
- get total(): number;
6
- get counters(): Map<T, number>;
7
- getCount(key: T): number | undefined;
8
- getFreq(key: T): number;
9
- addKeyCount(key: T, count: number): this;
10
- addKey(key: T): this;
11
- addKeys(keys: IterableLike<T>): void;
12
- addKeyCounts(values: IterableLike<[T, number]>): void;
13
- merge(...freqCounters: FreqCounter<T>[]): FreqCounter<T>;
14
- static create<T>(values?: IterableLike<T>): FreqCounter<T>;
15
- }
16
- //# sourceMappingURL=FreqCounter.d.ts.map
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FreqCounter = void 0;
4
- class FreqCounter {
5
- constructor() {
6
- this._total = 0;
7
- this._counters = new Map();
8
- }
9
- get total() {
10
- return this._total;
11
- }
12
- get counters() {
13
- return this._counters;
14
- }
15
- getCount(key) {
16
- return this._counters.get(key);
17
- }
18
- getFreq(key) {
19
- return (this.getCount(key) || 0) / (this._total || 1);
20
- }
21
- addKeyCount(key, count) {
22
- this._total += count;
23
- this._counters.set(key, (this._counters.get(key) || 0) + count);
24
- return this;
25
- }
26
- addKey(key) {
27
- return this.addKeyCount(key, 1);
28
- }
29
- addKeys(keys) {
30
- for (const key of keys) {
31
- this.addKey(key);
32
- }
33
- }
34
- addKeyCounts(values) {
35
- for (const pair of values) {
36
- this.addKeyCount(pair[0], pair[1]);
37
- }
38
- }
39
- merge(...freqCounters) {
40
- for (const fc of freqCounters) {
41
- this.addKeyCounts(fc._counters);
42
- }
43
- return this;
44
- }
45
- static create(values) {
46
- const fc = new FreqCounter();
47
- fc.addKeys(values || []);
48
- return fc;
49
- }
50
- }
51
- exports.FreqCounter = FreqCounter;
52
- //# sourceMappingURL=FreqCounter.js.map
@@ -1,65 +0,0 @@
1
- /** Only types that can be easily turned into strings */
2
- declare type P0 = string | number | boolean | RegExp | undefined;
3
- declare type Primitive = P0 | P0[];
4
- /**
5
- * Memorize the result of a function call to be returned on later calls with the same parameters.
6
- *
7
- * Note: The parameters are converted into a string: `key = args.join('>!@[')`
8
- *
9
- * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number
10
- * of cached values is between `size + 1` and `size * 2`.
11
- *
12
- * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared.
13
- *
14
- * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0.
15
- *
16
- * @param fn - function to be called.
17
- * @param size - size of cache
18
- */
19
- export declare function memorizer<F extends (...args: Primitive[]) => any, Args extends Parameters<F> = Parameters<F>, R extends ReturnType<F> = ReturnType<F>>(fn: F, size?: number): (...args: Args) => R;
20
- /**
21
- * Memorize the result of a function call to be returned on later calls with the same parameters.
22
- *
23
- * Note: `keyFn` is use to convert the function parameters into a string to look up in the cache.
24
- *
25
- * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number
26
- * of cached values is between `size + 1` and `size * 2`.
27
- *
28
- * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared.
29
- *
30
- * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0.
31
- *
32
- * @param fn - function to be memorized
33
- * @param keyFn - extracts a `key` value from the arguments to `fn` to be used as the key to the cache
34
- * @param size - size of the cache.
35
- * @returns A function
36
- */
37
- export declare function memorizerKeyBy<F extends (...args: any[]) => any, Args extends Parameters<F> = Parameters<F>, R extends ReturnType<F> = ReturnType<F>>(fn: F, keyFn: (...args: Args) => string, size?: number): (...args: Args) => R;
38
- /**
39
- * Create a function that memorizes the last call. If the next call is called with the same arguments, the
40
- * the last value is returned.
41
- * @param fn - function to memorize
42
- * @returns a new function.
43
- */
44
- export declare function memorizeLastCall<T>(fn: (...p: []) => T): (...p: []) => T;
45
- export declare function memorizeLastCall<T, K0>(fn: (...p: [K0]) => T): (...p: [K0]) => T;
46
- export declare function memorizeLastCall<T, K0, K1>(fn: (...p: [K0, K1]) => T): (...p: [K0, K1]) => T;
47
- export declare function memorizeLastCall<T, K0, K1, K2>(fn: (...p: [K0, K1, K2]) => T): (...p: [K0, K1, K2]) => T;
48
- export declare function memorizeLastCall<T, K0, K1, K2, K3>(fn: (...p: [K0, K1, K2, K3]) => T): (...p: [K0, K1, K2, K3]) => T;
49
- export declare function memorizeLastCall<T, K>(fn: (...p: [...K[]]) => T): (...p: [...K[]]) => T;
50
- /**
51
- * Creates a function that will call `fn` exactly once when invoked and remember the value returned.
52
- * All subsequent calls will return exactly same value.
53
- * @param fn - function to call
54
- * @returns a new function
55
- */
56
- export declare function callOnce<T>(fn: () => T): () => T;
57
- /**
58
- * Create a function that will memorize all calls to `fn` to ensure that `fn` is
59
- * called exactly once for each unique set of arguments.
60
- * @param fn - function to memorize
61
- * @returns a function
62
- */
63
- export declare function memorizerAll<K extends any[], T>(fn: (...p: K) => T): (...p: K) => T;
64
- export {};
65
- //# sourceMappingURL=Memorizer.d.ts.map
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.memorizerAll = exports.callOnce = exports.memorizeLastCall = exports.memorizerKeyBy = exports.memorizer = void 0;
4
- const util_1 = require("./util");
5
- /* eslint-disable @typescript-eslint/no-explicit-any */
6
- const defaultSize = 50000;
7
- /**
8
- * Memorize the result of a function call to be returned on later calls with the same parameters.
9
- *
10
- * Note: The parameters are converted into a string: `key = args.join('>!@[')`
11
- *
12
- * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number
13
- * of cached values is between `size + 1` and `size * 2`.
14
- *
15
- * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared.
16
- *
17
- * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0.
18
- *
19
- * @param fn - function to be called.
20
- * @param size - size of cache
21
- */
22
- function memorizer(fn, size) {
23
- return memorizerKeyBy(fn, (...args) => args.join('>!@['), size);
24
- }
25
- exports.memorizer = memorizer;
26
- /**
27
- * Memorize the result of a function call to be returned on later calls with the same parameters.
28
- *
29
- * Note: `keyFn` is use to convert the function parameters into a string to look up in the cache.
30
- *
31
- * For speed, it keeps two caches, L0 and L1. Each cache can contain up to `size` values. But that actual number
32
- * of cached values is between `size + 1` and `size * 2`.
33
- *
34
- * Caches are NOT sorted. Items are added to L0 until it is full. Once it is full, L1 takes over L0's values and L0 is cleared.
35
- *
36
- * If an item is not found in L0, L1 is checked before calling the `fn` and the resulting value store in L0.
37
- *
38
- * @param fn - function to be memorized
39
- * @param keyFn - extracts a `key` value from the arguments to `fn` to be used as the key to the cache
40
- * @param size - size of the cache.
41
- * @returns A function
42
- */
43
- function memorizerKeyBy(fn, keyFn, size = defaultSize) {
44
- let count = 0;
45
- let cacheL0 = Object.create(null);
46
- let cacheL1 = Object.create(null);
47
- return (...args) => {
48
- const key = keyFn(...args);
49
- if (key in cacheL0)
50
- return cacheL0[key];
51
- const v = key in cacheL1 ? cacheL1[key] : fn(...args);
52
- if (count >= size) {
53
- cacheL1 = cacheL0;
54
- cacheL0 = Object.create(null);
55
- count = 0;
56
- }
57
- cacheL0[key] = v;
58
- ++count;
59
- return v;
60
- };
61
- }
62
- exports.memorizerKeyBy = memorizerKeyBy;
63
- function memorizeLastCall(fn) {
64
- let last;
65
- return (...p) => {
66
- if (last && (0, util_1.isArrayEqual)(last.args, p)) {
67
- return last.value;
68
- }
69
- const args = p;
70
- const value = fn(...args);
71
- last = { args, value };
72
- return value;
73
- };
74
- }
75
- exports.memorizeLastCall = memorizeLastCall;
76
- /**
77
- * Creates a function that will call `fn` exactly once when invoked and remember the value returned.
78
- * All subsequent calls will return exactly same value.
79
- * @param fn - function to call
80
- * @returns a new function
81
- */
82
- function callOnce(fn) {
83
- let last;
84
- return () => {
85
- if (last) {
86
- return last.value;
87
- }
88
- last = {
89
- value: fn(),
90
- };
91
- return last.value;
92
- };
93
- }
94
- exports.callOnce = callOnce;
95
- /**
96
- * Create a function that will memorize all calls to `fn` to ensure that `fn` is
97
- * called exactly once for each unique set of arguments.
98
- * @param fn - function to memorize
99
- * @returns a function
100
- */
101
- function memorizerAll(fn) {
102
- const r = {};
103
- function find(p) {
104
- let n = r;
105
- for (const k of p) {
106
- if (!n)
107
- break;
108
- n = n.c?.get(k);
109
- }
110
- return n;
111
- }
112
- function set(p, v) {
113
- let n = r;
114
- for (const k of p) {
115
- const c = n.c?.get(k);
116
- if (c) {
117
- n = c;
118
- continue;
119
- }
120
- const r = {};
121
- n.c = n.c || new Map();
122
- n.c.set(k, r);
123
- n = r;
124
- }
125
- n.v = v;
126
- }
127
- return (...p) => {
128
- const f = find(p);
129
- if (f && 'v' in f) {
130
- return f.v;
131
- }
132
- const v = fn(...p);
133
- set(p, v);
134
- return v;
135
- };
136
- }
137
- exports.memorizerAll = memorizerAll;
138
- //# sourceMappingURL=Memorizer.js.map
@@ -1,23 +0,0 @@
1
- declare function addToHeap<T>(t: T[], c: T, compare: (a: T, b: T) => number): void;
2
- declare function takeFromHeap<T>(t: T[], compare: (a: T, b: T) => number): T | undefined;
3
- /**
4
- * MinHeapQueue - based upon a minHeap array.
5
- */
6
- export declare class MinHeapQueue<T> implements IterableIterator<T> {
7
- readonly compare: (a: T, b: T) => number;
8
- private values;
9
- constructor(compare: (a: T, b: T) => number);
10
- add(t: T): MinHeapQueue<T>;
11
- get length(): number;
12
- dequeue(): T | undefined;
13
- concat(i: Iterable<T>): MinHeapQueue<T>;
14
- next(): IteratorResult<T>;
15
- [Symbol.iterator](): IterableIterator<T>;
16
- clone(): MinHeapQueue<T>;
17
- }
18
- export declare const __testing__: {
19
- addToHeap: typeof addToHeap;
20
- takeFromHeap: typeof takeFromHeap;
21
- };
22
- export {};
23
- //# sourceMappingURL=MinHeapQueue.d.ts.map
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__testing__ = exports.MinHeapQueue = void 0;
4
- function swap(t, i, j) {
5
- const a = t[i];
6
- t[i] = t[j];
7
- t[j] = a;
8
- }
9
- function addToHeap(t, c, compare) {
10
- t.push(c);
11
- let b = t.length - 1;
12
- let a = (b - 1) >> 1;
13
- while (b > 0 && compare(t[a], t[b]) >= 0) {
14
- swap(t, a, b);
15
- b = a;
16
- a = (b - 1) >> 1;
17
- }
18
- }
19
- function takeFromHeap(t, compare) {
20
- const result = t[0];
21
- if (t.length <= 1) {
22
- t.length = 0;
23
- return result;
24
- }
25
- t[0] = t[t.length - 1];
26
- t.length -= 1;
27
- const m = t.length - 1;
28
- let i = 0;
29
- let j = i * 2 + 1;
30
- while (j < m) {
31
- const a = j;
32
- const b = j + 1;
33
- const k = compare(t[a], t[b]) < 0 ? a : b;
34
- if (compare(t[i], t[k]) <= 0) {
35
- break;
36
- }
37
- swap(t, i, k);
38
- i = k;
39
- j = i * 2 + 1;
40
- }
41
- if (j === m) {
42
- if (compare(t[i], t[j]) > 0) {
43
- swap(t, i, j);
44
- }
45
- }
46
- return result;
47
- }
48
- /**
49
- * MinHeapQueue - based upon a minHeap array.
50
- */
51
- class MinHeapQueue {
52
- constructor(compare) {
53
- this.compare = compare;
54
- this.values = [];
55
- }
56
- add(t) {
57
- addToHeap(this.values, t, this.compare);
58
- return this;
59
- }
60
- get length() {
61
- return this.values.length;
62
- }
63
- dequeue() {
64
- return takeFromHeap(this.values, this.compare);
65
- }
66
- concat(i) {
67
- for (const v of i) {
68
- this.add(v);
69
- }
70
- return this;
71
- }
72
- next() {
73
- const value = this.dequeue();
74
- return value !== undefined
75
- ? {
76
- value,
77
- }
78
- : {
79
- value,
80
- done: true,
81
- };
82
- }
83
- [Symbol.iterator]() {
84
- return this;
85
- }
86
- clone() {
87
- const clone = new MinHeapQueue(this.compare);
88
- clone.values = this.values.concat();
89
- return clone;
90
- }
91
- }
92
- exports.MinHeapQueue = MinHeapQueue;
93
- exports.__testing__ = {
94
- addToHeap,
95
- takeFromHeap,
96
- };
97
- //# sourceMappingURL=MinHeapQueue.js.map
@@ -1,32 +0,0 @@
1
- export interface PairHeapNode<T> {
2
- /** Value */
3
- v: T;
4
- /** Siblings */
5
- s: PairHeapNode<T> | undefined;
6
- /** Children */
7
- c: PairHeapNode<T> | undefined;
8
- }
9
- export declare type CompareFn<T> = (a: T, b: T) => number;
10
- export declare class PairingHeap<T> implements IterableIterator<T> {
11
- readonly compare: CompareFn<T>;
12
- private _heap;
13
- private _size;
14
- constructor(compare: CompareFn<T>);
15
- add(v: T): this;
16
- dequeue(): T | undefined;
17
- concat(i: Iterable<T>): this;
18
- next(): IteratorResult<T>;
19
- peek(): T | undefined;
20
- [Symbol.iterator](): IterableIterator<T>;
21
- get length(): number;
22
- }
23
- declare function insert<T>(compare: CompareFn<T>, heap: PairHeapNode<T> | undefined, v: T): PairHeapNode<T>;
24
- declare function merge<T>(compare: CompareFn<T>, a: PairHeapNode<T>, b: PairHeapNode<T>): PairHeapNode<T>;
25
- declare function mergeSiblings<T>(compare: CompareFn<T>, n: PairHeapNode<T>): PairHeapNode<T>;
26
- export declare const heapMethods: {
27
- insert: typeof insert;
28
- merge: typeof merge;
29
- mergeSiblings: typeof mergeSiblings;
30
- };
31
- export {};
32
- //# sourceMappingURL=PairingHeap.d.ts.map