@ls-stack/utils 1.13.2 → 2.0.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 (140) hide show
  1. package/dist/arrayUtils.cjs +91 -0
  2. package/dist/arrayUtils.d.cts +51 -0
  3. package/dist/arrayUtils.js +1 -2
  4. package/dist/assertions.cjs +99 -0
  5. package/dist/assertions.d.cts +17 -0
  6. package/dist/assertions.js +1 -2
  7. package/dist/castValues.cjs +41 -0
  8. package/dist/castValues.d.cts +4 -0
  9. package/dist/castValues.js +0 -1
  10. package/dist/{chunk-FYMTZQ42.js → chunk-4UGSP3L3.js} +0 -1
  11. package/dist/{chunk-HLFWWIDK.js → chunk-5DZT3Z5Z.js} +0 -1
  12. package/dist/{chunk-W7X6NSGR.js → chunk-AZBBTE33.js} +0 -1
  13. package/dist/{chunk-MMKMF4GG.js → chunk-IATIXMCE.js} +0 -1
  14. package/dist/chunk-JOBPQAI3.js +147 -0
  15. package/dist/{chunk-M74KKYE4.js → chunk-KCOXGSRA.js} +0 -1
  16. package/dist/{chunk-NKCC3375.js → chunk-NWXBMMHO.js} +0 -1
  17. package/dist/{chunk-SNAAKCTH.js → chunk-RVVH3MDA.js} +0 -1
  18. package/dist/{chunk-4QK76IRX.js → chunk-T5WDDPFI.js} +1 -6
  19. package/dist/{chunk-GLZ5MZC5.js → chunk-V2L472LS.js} +0 -30
  20. package/dist/consoleFmt.cjs +84 -0
  21. package/dist/consoleFmt.d.cts +48 -0
  22. package/dist/consoleFmt.js +0 -1
  23. package/dist/conversions.cjs +44 -0
  24. package/dist/conversions.d.cts +3 -0
  25. package/dist/conversions.js +1 -2
  26. package/dist/createThrottleController.cjs +183 -0
  27. package/dist/createThrottleController.d.cts +16 -0
  28. package/dist/createThrottleController.js +2 -3
  29. package/dist/debounce.cjs +125 -0
  30. package/dist/debounce.d.cts +45 -0
  31. package/dist/debounce.js +0 -1
  32. package/dist/dedent.cjs +57 -0
  33. package/dist/dedent.d.cts +4 -0
  34. package/dist/dedent.js +0 -1
  35. package/dist/deepEqual.cjs +88 -0
  36. package/dist/deepEqual.d.cts +4 -0
  37. package/dist/deepEqual.js +1 -2
  38. package/dist/enhancedMap.cjs +128 -0
  39. package/dist/enhancedMap.d.cts +20 -0
  40. package/dist/enhancedMap.d.ts +0 -2
  41. package/dist/enhancedMap.js +2 -3
  42. package/dist/exhaustiveMatch.cjs +55 -0
  43. package/dist/exhaustiveMatch.d.cts +6 -0
  44. package/dist/exhaustiveMatch.js +0 -1
  45. package/dist/interpolate.cjs +88 -0
  46. package/dist/interpolate.d.cts +11 -0
  47. package/dist/interpolate.js +2 -3
  48. package/dist/levenshtein.cjs +180 -0
  49. package/dist/levenshtein.d.cts +5 -0
  50. package/dist/levenshtein.js +0 -1
  51. package/dist/main.cjs +4 -0
  52. package/dist/main.d.cts +2 -0
  53. package/dist/main.d.ts +1 -1
  54. package/dist/main.js +0 -1
  55. package/dist/mathUtils.cjs +50 -0
  56. package/dist/mathUtils.d.cts +6 -0
  57. package/dist/mathUtils.js +1 -2
  58. package/dist/objUtils.cjs +67 -0
  59. package/dist/objUtils.d.cts +7 -0
  60. package/dist/objUtils.js +1 -2
  61. package/dist/parallelAsyncCalls.cjs +265 -0
  62. package/dist/{parallelAsyncResultCalls.d.ts → parallelAsyncCalls.d.cts} +7 -7
  63. package/dist/parallelAsyncCalls.d.ts +76 -0
  64. package/dist/{parallelAsyncResultCalls.js → parallelAsyncCalls.js} +7 -9
  65. package/dist/promiseUtils.cjs +38 -0
  66. package/dist/promiseUtils.d.cts +8 -0
  67. package/dist/promiseUtils.js +0 -1
  68. package/dist/rsResult.cjs +179 -0
  69. package/dist/rsResult.d.cts +88 -0
  70. package/dist/rsResult.d.ts +33 -63
  71. package/dist/rsResult.js +6 -10
  72. package/dist/runShellCmd.cjs +127 -0
  73. package/dist/runShellCmd.d.cts +23 -0
  74. package/dist/runShellCmd.d.ts +2 -1
  75. package/dist/runShellCmd.js +9 -4
  76. package/dist/shallowEqual.cjs +88 -0
  77. package/dist/shallowEqual.d.cts +4 -0
  78. package/dist/shallowEqual.js +0 -1
  79. package/dist/sleep.cjs +32 -0
  80. package/dist/sleep.d.cts +3 -0
  81. package/dist/sleep.js +1 -2
  82. package/dist/stringUtils.cjs +66 -0
  83. package/dist/stringUtils.d.cts +16 -0
  84. package/dist/stringUtils.d.ts +1 -3
  85. package/dist/stringUtils.js +1 -4
  86. package/dist/testUtils.cjs +357 -0
  87. package/dist/testUtils.d.cts +38 -0
  88. package/dist/testUtils.js +5 -6
  89. package/dist/typingFnUtils.cjs +55 -0
  90. package/dist/typingFnUtils.d.cts +15 -0
  91. package/dist/typingFnUtils.js +0 -1
  92. package/dist/typingTestUtils.cjs +43 -0
  93. package/dist/typingTestUtils.d.cts +12 -0
  94. package/dist/typingTestUtils.js +0 -1
  95. package/dist/typingUtils.cjs +18 -0
  96. package/dist/typingUtils.d.cts +11 -0
  97. package/dist/typingUtils.js +0 -1
  98. package/dist/yamlStringify.cjs +346 -0
  99. package/dist/yamlStringify.d.cts +8 -0
  100. package/dist/yamlStringify.js +3 -4
  101. package/package.json +64 -34
  102. package/dist/arrayUtils.js.map +0 -1
  103. package/dist/assertions.js.map +0 -1
  104. package/dist/castValues.js.map +0 -1
  105. package/dist/chunk-4QK76IRX.js.map +0 -1
  106. package/dist/chunk-FYMTZQ42.js.map +0 -1
  107. package/dist/chunk-GLZ5MZC5.js.map +0 -1
  108. package/dist/chunk-HLFWWIDK.js.map +0 -1
  109. package/dist/chunk-I7ZDKDUM.js +0 -217
  110. package/dist/chunk-I7ZDKDUM.js.map +0 -1
  111. package/dist/chunk-M74KKYE4.js.map +0 -1
  112. package/dist/chunk-MMKMF4GG.js.map +0 -1
  113. package/dist/chunk-NKCC3375.js.map +0 -1
  114. package/dist/chunk-SNAAKCTH.js.map +0 -1
  115. package/dist/chunk-W7X6NSGR.js.map +0 -1
  116. package/dist/consoleFmt.js.map +0 -1
  117. package/dist/conversions.js.map +0 -1
  118. package/dist/createThrottleController.js.map +0 -1
  119. package/dist/debounce.js.map +0 -1
  120. package/dist/dedent.js.map +0 -1
  121. package/dist/deepEqual.js.map +0 -1
  122. package/dist/enhancedMap.js.map +0 -1
  123. package/dist/exhaustiveMatch.js.map +0 -1
  124. package/dist/interpolate.js.map +0 -1
  125. package/dist/levenshtein.js.map +0 -1
  126. package/dist/main.js.map +0 -1
  127. package/dist/mathUtils.js.map +0 -1
  128. package/dist/objUtils.js.map +0 -1
  129. package/dist/parallelAsyncResultCalls.js.map +0 -1
  130. package/dist/promiseUtils.js.map +0 -1
  131. package/dist/rsResult.js.map +0 -1
  132. package/dist/runShellCmd.js.map +0 -1
  133. package/dist/shallowEqual.js.map +0 -1
  134. package/dist/sleep.js.map +0 -1
  135. package/dist/stringUtils.js.map +0 -1
  136. package/dist/testUtils.js.map +0 -1
  137. package/dist/typingFnUtils.js.map +0 -1
  138. package/dist/typingTestUtils.js.map +0 -1
  139. package/dist/typingUtils.js.map +0 -1
  140. package/dist/yamlStringify.js.map +0 -1
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/enhancedMap.ts
21
+ var enhancedMap_exports = {};
22
+ __export(enhancedMap_exports, {
23
+ EnhancedMap: () => EnhancedMap,
24
+ enhancedMapReject: () => enhancedMapReject
25
+ });
26
+ module.exports = __toCommonJS(enhancedMap_exports);
27
+
28
+ // src/assertions.ts
29
+ function isFunction(value) {
30
+ return typeof value === "function";
31
+ }
32
+
33
+ // src/enhancedMap.ts
34
+ var enhancedMapReject = Symbol();
35
+ var EnhancedMap = class _EnhancedMap extends Map {
36
+ find(predicate) {
37
+ for (const [key, value] of this) {
38
+ if (predicate(value, key)) {
39
+ return { key, value };
40
+ }
41
+ }
42
+ return void 0;
43
+ }
44
+ setMultiple(...values) {
45
+ if (Array.isArray(values[0])) {
46
+ for (const [key, value] of values) {
47
+ this.set(key, value);
48
+ }
49
+ } else {
50
+ for (const [key, value] of Object.entries(values[0])) {
51
+ this.set(key, value);
52
+ }
53
+ }
54
+ return this;
55
+ }
56
+ getOrThrow(key) {
57
+ const value = this.get(key);
58
+ if (value === void 0) {
59
+ throw new Error(`Key ${key} not found in EnhancedMap`);
60
+ }
61
+ return value;
62
+ }
63
+ getOrInsert(key, fallback) {
64
+ if (!this.has(key)) {
65
+ this.set(key, fallback());
66
+ }
67
+ return this.getOrThrow(key);
68
+ }
69
+ toFilteredValues(predicate) {
70
+ const values = [];
71
+ for (const [key, value] of this) {
72
+ if (predicate(value, key)) {
73
+ values.push(value);
74
+ }
75
+ }
76
+ return values;
77
+ }
78
+ toMap(mapFunction) {
79
+ const values = [];
80
+ for (const [key, value] of this) {
81
+ const result = mapFunction(value, key, enhancedMapReject);
82
+ if (result !== enhancedMapReject) {
83
+ values.push(result);
84
+ }
85
+ }
86
+ return values;
87
+ }
88
+ toObjMap(mapFunction) {
89
+ const values = {};
90
+ for (const [key, value] of this) {
91
+ const result = mapFunction(value, key);
92
+ if (result) {
93
+ values[result[0]] = result[1];
94
+ }
95
+ }
96
+ return values;
97
+ }
98
+ toValues() {
99
+ return [...this.values()];
100
+ }
101
+ toKeys() {
102
+ return [...this.keys()];
103
+ }
104
+ static from(array, mapFunction) {
105
+ const map = new _EnhancedMap();
106
+ if (!array) return map;
107
+ const isFn = isFunction(mapFunction);
108
+ for (const item of array) {
109
+ if (isFn) {
110
+ const result = mapFunction(item);
111
+ if (result) {
112
+ map.set(result[0], result[1]);
113
+ }
114
+ } else {
115
+ const key = item[mapFunction];
116
+ if (key !== void 0) {
117
+ map.set(key, item);
118
+ }
119
+ }
120
+ }
121
+ return map;
122
+ }
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ EnhancedMap,
127
+ enhancedMapReject
128
+ });
@@ -0,0 +1,20 @@
1
+ declare const enhancedMapReject: unique symbol;
2
+ declare class EnhancedMap<K, V> extends Map<K, V> {
3
+ find(predicate: (value: V, key: K) => boolean): {
4
+ key: K;
5
+ value: V;
6
+ } | undefined;
7
+ setMultiple(values: Record<K & string, V>): this;
8
+ setMultiple(...values: [key: K, value: V][]): this;
9
+ getOrThrow(key: K): V;
10
+ getOrInsert(key: K, fallback: () => V): V;
11
+ toFilteredValues(predicate: (value: V, key: K) => boolean): V[];
12
+ toMap<T>(mapFunction: (value: V, key: K, reject: typeof enhancedMapReject) => T | typeof enhancedMapReject): T[];
13
+ toObjMap<ObjKey extends PropertyKey, ObjValue>(mapFunction: (value: V, key: K) => [key: ObjKey, value: ObjValue] | false): Record<ObjKey, ObjValue>;
14
+ toValues(): V[];
15
+ toKeys(): K[];
16
+ static from<T extends Record<string, unknown>, K extends keyof T>(array: T[] | Iterable<T> | null | undefined, key: K): EnhancedMap<T[K], T>;
17
+ static from<T, K, V>(array: T[] | Iterable<T> | null | undefined, mapFunction: (item: T) => [key: K, value: V] | false): EnhancedMap<K, V>;
18
+ }
19
+
20
+ export { EnhancedMap, enhancedMapReject };
@@ -13,8 +13,6 @@ declare class EnhancedMap<K, V> extends Map<K, V> {
13
13
  toObjMap<ObjKey extends PropertyKey, ObjValue>(mapFunction: (value: V, key: K) => [key: ObjKey, value: ObjValue] | false): Record<ObjKey, ObjValue>;
14
14
  toValues(): V[];
15
15
  toKeys(): K[];
16
- /** @deprecated, will be removed in v5 use `from` method instead */
17
- static fromIterMap<T, K, V>(array: T[] | Iterable<T>, mapFunction: (item: T) => [key: K, value: V] | false): EnhancedMap<K, V>;
18
16
  static from<T extends Record<string, unknown>, K extends keyof T>(array: T[] | Iterable<T> | null | undefined, key: K): EnhancedMap<T[K], T>;
19
17
  static from<T, K, V>(array: T[] | Iterable<T> | null | undefined, mapFunction: (item: T) => [key: K, value: V] | false): EnhancedMap<K, V>;
20
18
  }
@@ -1,10 +1,9 @@
1
1
  import {
2
2
  EnhancedMap,
3
3
  enhancedMapReject
4
- } from "./chunk-4QK76IRX.js";
5
- import "./chunk-FYMTZQ42.js";
4
+ } from "./chunk-T5WDDPFI.js";
5
+ import "./chunk-4UGSP3L3.js";
6
6
  export {
7
7
  EnhancedMap,
8
8
  enhancedMapReject
9
9
  };
10
- //# sourceMappingURL=enhancedMap.js.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/exhaustiveMatch.ts
21
+ var exhaustiveMatch_exports = {};
22
+ __export(exhaustiveMatch_exports, {
23
+ exhaustiveMatch: () => exhaustiveMatch
24
+ });
25
+ module.exports = __toCommonJS(exhaustiveMatch_exports);
26
+ function exhaustiveMatch(value) {
27
+ function matchWith(pattern) {
28
+ const result = pattern[value];
29
+ if (typeof result === "function") {
30
+ return result();
31
+ }
32
+ if (result === "_nxt") {
33
+ const keys = Object.keys(pattern);
34
+ const nextIndex = keys.indexOf(value) + 1;
35
+ for (let i = nextIndex; i < keys.length; i++) {
36
+ const nextMatch = pattern[keys[i]];
37
+ if (typeof nextMatch === "function") {
38
+ return nextMatch();
39
+ }
40
+ }
41
+ }
42
+ throw new Error(`Exhaustive match failed: no match for ${value}`);
43
+ }
44
+ function withObject(pattern) {
45
+ return pattern[value];
46
+ }
47
+ return {
48
+ with: matchWith,
49
+ withObject
50
+ };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ exhaustiveMatch
55
+ });
@@ -0,0 +1,6 @@
1
+ declare function exhaustiveMatch<T extends string>(value: T): {
2
+ with: <R>(pattern: { [K in T]: "_nxt" | "_never" | (() => R); }) => R;
3
+ withObject: <R>(pattern: Record<T, R>) => R;
4
+ };
5
+
6
+ export { exhaustiveMatch };
@@ -28,4 +28,3 @@ function exhaustiveMatch(value) {
28
28
  export {
29
29
  exhaustiveMatch
30
30
  };
31
- //# sourceMappingURL=exhaustiveMatch.js.map
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
19
+
20
+ // src/interpolate.ts
21
+ var interpolate_exports = {};
22
+ __export(interpolate_exports, {
23
+ cyclicLerp: () => cyclicLerp,
24
+ interpolate: () => interpolate
25
+ });
26
+ module.exports = __toCommonJS(interpolate_exports);
27
+
28
+ // src/assertions.ts
29
+ function invariant(condition, errorMsg = "Invariant violation") {
30
+ if (!condition) {
31
+ throw new Error(`Invariant violation: ${errorMsg}`);
32
+ }
33
+ }
34
+
35
+ // src/mathUtils.ts
36
+ function clampMax(value, max) {
37
+ return value > max ? max : value;
38
+ }
39
+ function clampMin(value, min) {
40
+ return value < min ? min : value;
41
+ }
42
+ function clampRange(num, v1, v2) {
43
+ if (v2 > v1) {
44
+ return clamp(num, v1, v2);
45
+ }
46
+ return clamp(num, v2, v1);
47
+ }
48
+ function clamp(num, min, max) {
49
+ return num > max ? max : num < min ? min : num;
50
+ }
51
+
52
+ // src/interpolate.ts
53
+ function mod(n, m) {
54
+ return (n % m + m) % m;
55
+ }
56
+ function cyclicLerp(input, [inStart, inEnd], [outStart, outEnd]) {
57
+ return mod((input - inStart) / (inEnd - inStart), 1) * (outEnd - outStart) + outStart;
58
+ }
59
+ function findRange(input, inputRange) {
60
+ for (let i = 1; i < inputRange.length - 1; i++) {
61
+ if (inputRange[i] >= input) return i - 1;
62
+ }
63
+ return inputRange.length - 2;
64
+ }
65
+ function interpolate({
66
+ input,
67
+ in: inputRange,
68
+ out,
69
+ clamp: clamp2 = true
70
+ }) {
71
+ invariant(
72
+ inputRange.length === out.length,
73
+ "Ranges must have the same length"
74
+ );
75
+ const range = findRange(input, inputRange);
76
+ const inStart = inputRange[range];
77
+ const inEnd = inputRange[range + 1];
78
+ const outStart = out[range];
79
+ const outEnd = out[range + 1];
80
+ const interpolatedValue = (input - inStart) / (inEnd - inStart) * (outEnd - outStart) + outStart;
81
+ const outputIsAscending = outStart < outEnd;
82
+ return clamp2 === "start" ? outputIsAscending ? clampMin(interpolatedValue, outStart) : clampMax(interpolatedValue, outStart) : clamp2 === "end" ? outputIsAscending ? clampMax(interpolatedValue, outEnd) : clampMin(interpolatedValue, outEnd) : clamp2 ? clampRange(interpolatedValue, outStart, outEnd) : interpolatedValue;
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ cyclicLerp,
87
+ interpolate
88
+ });
@@ -0,0 +1,11 @@
1
+ type Interval = [number, number];
2
+ declare function cyclicLerp(input: number, [inStart, inEnd]: Interval, [outStart, outEnd]: Interval): number;
3
+ type InterpolateArgs = {
4
+ input: number;
5
+ in: number[];
6
+ out: number[];
7
+ clamp?: boolean | 'start' | 'end';
8
+ };
9
+ declare function interpolate({ input, in: inputRange, out, clamp, }: InterpolateArgs): number;
10
+
11
+ export { cyclicLerp, interpolate };
@@ -2,10 +2,10 @@ import {
2
2
  clampMax,
3
3
  clampMin,
4
4
  clampRange
5
- } from "./chunk-NKCC3375.js";
5
+ } from "./chunk-NWXBMMHO.js";
6
6
  import {
7
7
  invariant
8
- } from "./chunk-FYMTZQ42.js";
8
+ } from "./chunk-4UGSP3L3.js";
9
9
 
10
10
  // src/interpolate.ts
11
11
  function mod(n, m) {
@@ -43,4 +43,3 @@ export {
43
43
  cyclicLerp,
44
44
  interpolate
45
45
  };
46
- //# sourceMappingURL=interpolate.js.map
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/levenshtein.ts
21
+ var levenshtein_exports = {};
22
+ __export(levenshtein_exports, {
23
+ getClosestString: () => getClosestString,
24
+ getClosestStringsUpToDist: () => getClosestStringsUpToDist,
25
+ levenshteinDistance: () => levenshteinDistance
26
+ });
27
+ module.exports = __toCommonJS(levenshtein_exports);
28
+ var peq = new Uint32Array(65536);
29
+ var myers_32 = (a, b) => {
30
+ const n = a.length;
31
+ const m = b.length;
32
+ const lst = 1 << n - 1;
33
+ let pv = -1;
34
+ let mv = 0;
35
+ let sc = n;
36
+ let i = n;
37
+ while (i--) {
38
+ peq[a.charCodeAt(i)] |= 1 << i;
39
+ }
40
+ for (i = 0; i < m; i++) {
41
+ let eq = peq[b.charCodeAt(i)];
42
+ const xv = eq | mv;
43
+ eq |= (eq & pv) + pv ^ pv;
44
+ mv |= ~(eq | pv);
45
+ pv &= eq;
46
+ if (mv & lst) {
47
+ sc++;
48
+ }
49
+ if (pv & lst) {
50
+ sc--;
51
+ }
52
+ mv = mv << 1 | 1;
53
+ pv = pv << 1 | ~(xv | mv);
54
+ mv &= xv;
55
+ }
56
+ i = n;
57
+ while (i--) {
58
+ peq[a.charCodeAt(i)] = 0;
59
+ }
60
+ return sc;
61
+ };
62
+ var myers_x = (b, a) => {
63
+ const n = a.length;
64
+ const m = b.length;
65
+ const mhc = [];
66
+ const phc = [];
67
+ const hsize = Math.ceil(n / 32);
68
+ const vsize = Math.ceil(m / 32);
69
+ for (let i = 0; i < hsize; i++) {
70
+ phc[i] = -1;
71
+ mhc[i] = 0;
72
+ }
73
+ let j = 0;
74
+ for (; j < vsize - 1; j++) {
75
+ let mv2 = 0;
76
+ let pv2 = -1;
77
+ const start2 = j * 32;
78
+ const vlen2 = Math.min(32, m) + start2;
79
+ for (let k = start2; k < vlen2; k++) {
80
+ peq[b.charCodeAt(k)] |= 1 << k;
81
+ }
82
+ for (let i = 0; i < n; i++) {
83
+ const eq = peq[a.charCodeAt(i)];
84
+ const pb = phc[i / 32 | 0] >>> i & 1;
85
+ const mb = mhc[i / 32 | 0] >>> i & 1;
86
+ const xv = eq | mv2;
87
+ const xh = ((eq | mb) & pv2) + pv2 ^ pv2 | eq | mb;
88
+ let ph = mv2 | ~(xh | pv2);
89
+ let mh = pv2 & xh;
90
+ if (ph >>> 31 ^ pb) {
91
+ phc[i / 32 | 0] ^= 1 << i;
92
+ }
93
+ if (mh >>> 31 ^ mb) {
94
+ mhc[i / 32 | 0] ^= 1 << i;
95
+ }
96
+ ph = ph << 1 | pb;
97
+ mh = mh << 1 | mb;
98
+ pv2 = mh | ~(xv | ph);
99
+ mv2 = ph & xv;
100
+ }
101
+ for (let k = start2; k < vlen2; k++) {
102
+ peq[b.charCodeAt(k)] = 0;
103
+ }
104
+ }
105
+ let mv = 0;
106
+ let pv = -1;
107
+ const start = j * 32;
108
+ const vlen = Math.min(32, m - start) + start;
109
+ for (let k = start; k < vlen; k++) {
110
+ peq[b.charCodeAt(k)] |= 1 << k;
111
+ }
112
+ let score = m;
113
+ for (let i = 0; i < n; i++) {
114
+ const eq = peq[a.charCodeAt(i)];
115
+ const pb = phc[i / 32 | 0] >>> i & 1;
116
+ const mb = mhc[i / 32 | 0] >>> i & 1;
117
+ const xv = eq | mv;
118
+ const xh = ((eq | mb) & pv) + pv ^ pv | eq | mb;
119
+ let ph = mv | ~(xh | pv);
120
+ let mh = pv & xh;
121
+ score += ph >>> m - 1 & 1;
122
+ score -= mh >>> m - 1 & 1;
123
+ if (ph >>> 31 ^ pb) {
124
+ phc[i / 32 | 0] ^= 1 << i;
125
+ }
126
+ if (mh >>> 31 ^ mb) {
127
+ mhc[i / 32 | 0] ^= 1 << i;
128
+ }
129
+ ph = ph << 1 | pb;
130
+ mh = mh << 1 | mb;
131
+ pv = mh | ~(xv | ph);
132
+ mv = ph & xv;
133
+ }
134
+ for (let k = start; k < vlen; k++) {
135
+ peq[b.charCodeAt(k)] = 0;
136
+ }
137
+ return score;
138
+ };
139
+ function levenshteinDistance(a, b) {
140
+ if (a.length < b.length) {
141
+ const tmp = b;
142
+ b = a;
143
+ a = tmp;
144
+ }
145
+ if (b.length === 0) {
146
+ return a.length;
147
+ }
148
+ if (a.length <= 32) {
149
+ return myers_32(a, b);
150
+ }
151
+ return myers_x(a, b);
152
+ }
153
+ function getClosestString(str, arr, maxDistance = 2) {
154
+ let min_distance = Infinity;
155
+ let closestString;
156
+ for (let i = 0; i < arr.length; i++) {
157
+ const dist = levenshteinDistance(str, arr[i]);
158
+ if (dist < min_distance && dist <= maxDistance) {
159
+ min_distance = dist;
160
+ closestString = arr[i];
161
+ }
162
+ }
163
+ return closestString;
164
+ }
165
+ function getClosestStringsUpToDist(str, arr, maxDistance = 2) {
166
+ const distanceMap = /* @__PURE__ */ new Map();
167
+ for (const item of arr) {
168
+ const distance = levenshteinDistance(str, item);
169
+ if (distance <= maxDistance) {
170
+ distanceMap.set(item, distance);
171
+ }
172
+ }
173
+ return Array.from(distanceMap.entries()).sort((a, b) => a[1] - b[1]).map(([item]) => item);
174
+ }
175
+ // Annotate the CommonJS export names for ESM import in node:
176
+ 0 && (module.exports = {
177
+ getClosestString,
178
+ getClosestStringsUpToDist,
179
+ levenshteinDistance
180
+ });
@@ -0,0 +1,5 @@
1
+ declare function levenshteinDistance(a: string, b: string): number;
2
+ declare function getClosestString(str: string, arr: readonly string[], maxDistance?: number): string | undefined;
3
+ declare function getClosestStringsUpToDist(str: string, arr: readonly string[], maxDistance?: number): string[];
4
+
5
+ export { getClosestString, getClosestStringsUpToDist, levenshteinDistance };
@@ -151,4 +151,3 @@ export {
151
151
  getClosestStringsUpToDist,
152
152
  levenshteinDistance
153
153
  };
154
- //# sourceMappingURL=levenshtein.js.map
package/dist/main.cjs ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ // src/main.ts
4
+ throw new Error("do not use this file");
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/main.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  ///<reference path="main.d.ts" />
15
15
  ///<reference path="mathUtils.d.ts" />
16
16
  ///<reference path="objUtils.d.ts" />
17
- ///<reference path="parallelAsyncResultCalls.d.ts" />
17
+ ///<reference path="parallelAsyncCalls.d.ts" />
18
18
  ///<reference path="promiseUtils.d.ts" />
19
19
  ///<reference path="rsResult.d.ts" />
20
20
  ///<reference path="runShellCmd.d.ts" />
package/dist/main.js CHANGED
@@ -1,3 +1,2 @@
1
1
  // src/main.ts
2
2
  throw new Error("do not use this file");
3
- //# sourceMappingURL=main.js.map
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/mathUtils.ts
21
+ var mathUtils_exports = {};
22
+ __export(mathUtils_exports, {
23
+ clamp: () => clamp,
24
+ clampMax: () => clampMax,
25
+ clampMin: () => clampMin,
26
+ clampRange: () => clampRange
27
+ });
28
+ module.exports = __toCommonJS(mathUtils_exports);
29
+ function clampMax(value, max) {
30
+ return value > max ? max : value;
31
+ }
32
+ function clampMin(value, min) {
33
+ return value < min ? min : value;
34
+ }
35
+ function clampRange(num, v1, v2) {
36
+ if (v2 > v1) {
37
+ return clamp(num, v1, v2);
38
+ }
39
+ return clamp(num, v2, v1);
40
+ }
41
+ function clamp(num, min, max) {
42
+ return num > max ? max : num < min ? min : num;
43
+ }
44
+ // Annotate the CommonJS export names for ESM import in node:
45
+ 0 && (module.exports = {
46
+ clamp,
47
+ clampMax,
48
+ clampMin,
49
+ clampRange
50
+ });
@@ -0,0 +1,6 @@
1
+ declare function clampMax(value: number, max: number): number;
2
+ declare function clampMin(value: number, min: number): number;
3
+ declare function clampRange(num: number, v1: number, v2: number): number;
4
+ declare function clamp(num: number, min: number, max: number): number;
5
+
6
+ export { clamp, clampMax, clampMin, clampRange };
package/dist/mathUtils.js CHANGED
@@ -3,11 +3,10 @@ import {
3
3
  clampMax,
4
4
  clampMin,
5
5
  clampRange
6
- } from "./chunk-NKCC3375.js";
6
+ } from "./chunk-NWXBMMHO.js";
7
7
  export {
8
8
  clamp,
9
9
  clampMax,
10
10
  clampMin,
11
11
  clampRange
12
12
  };
13
- //# sourceMappingURL=mathUtils.js.map