umt 2.6.0 → 2.8.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 (121) hide show
  1. package/README.md +25 -0
  2. package/module/Crypto/decodeBase32.d.ts +7 -0
  3. package/module/Crypto/decodeBase32.js +27 -0
  4. package/module/Crypto/decodeBase32.js.map +1 -0
  5. package/module/Crypto/decodeBase32ToString.d.ts +7 -0
  6. package/module/Crypto/decodeBase32ToString.js +11 -0
  7. package/module/Crypto/decodeBase32ToString.js.map +1 -0
  8. package/module/Crypto/decodeBase58.d.ts +7 -0
  9. package/module/Crypto/decodeBase58.js +34 -0
  10. package/module/Crypto/decodeBase58.js.map +1 -0
  11. package/module/Crypto/decodeBase58ToString.d.ts +7 -0
  12. package/module/Crypto/decodeBase58ToString.js +11 -0
  13. package/module/Crypto/decodeBase58ToString.js.map +1 -0
  14. package/module/Crypto/encodeBase32.d.ts +7 -0
  15. package/module/Crypto/encodeBase32.js +28 -0
  16. package/module/Crypto/encodeBase32.js.map +1 -0
  17. package/module/Crypto/encodeBase58.d.ts +7 -0
  18. package/module/Crypto/encodeBase58.js +29 -0
  19. package/module/Crypto/encodeBase58.js.map +1 -0
  20. package/module/Crypto/index.d.ts +6 -0
  21. package/module/Crypto/index.js +7 -0
  22. package/module/Crypto/index.js.map +1 -0
  23. package/module/DataStructure/index.d.ts +1 -0
  24. package/module/DataStructure/index.js +2 -0
  25. package/module/DataStructure/index.js.map +1 -0
  26. package/module/DataStructure/priorityQueue.d.ts +241 -0
  27. package/module/DataStructure/priorityQueue.js +327 -0
  28. package/module/DataStructure/priorityQueue.js.map +1 -0
  29. package/module/Math/correlationCoefficient.d.ts +11 -0
  30. package/module/Math/correlationCoefficient.js +40 -0
  31. package/module/Math/correlationCoefficient.js.map +1 -0
  32. package/module/Math/index.d.ts +3 -0
  33. package/module/Math/index.js +3 -0
  34. package/module/Math/index.js.map +1 -1
  35. package/module/Math/mode.d.ts +10 -0
  36. package/module/Math/mode.js +31 -0
  37. package/module/Math/mode.js.map +1 -0
  38. package/module/Math/percentile.d.ts +11 -0
  39. package/module/Math/percentile.js +31 -0
  40. package/module/Math/percentile.js.map +1 -0
  41. package/module/Math/solveEquation.js +1 -1
  42. package/module/Math/solveEquation.js.map +1 -1
  43. package/module/String/fuzzySearch.d.ts +14 -0
  44. package/module/String/fuzzySearch.js +27 -0
  45. package/module/String/fuzzySearch.js.map +1 -0
  46. package/module/String/index.d.ts +4 -0
  47. package/module/String/index.js +4 -0
  48. package/module/String/index.js.map +1 -1
  49. package/module/String/reverseString.js +1 -1
  50. package/module/String/reverseString.js.map +1 -1
  51. package/module/String/slugify.d.ts +10 -0
  52. package/module/String/slugify.js +21 -0
  53. package/module/String/slugify.js.map +1 -0
  54. package/module/String/truncate.d.ts +12 -0
  55. package/module/String/truncate.js +21 -0
  56. package/module/String/truncate.js.map +1 -0
  57. package/module/String/unescapeHtml.d.ts +17 -0
  58. package/module/String/unescapeHtml.js +45 -0
  59. package/module/String/unescapeHtml.js.map +1 -0
  60. package/module/Validate/index.d.ts +1 -0
  61. package/module/Validate/index.js +1 -0
  62. package/module/Validate/index.js.map +1 -1
  63. package/module/Validate/isDeepEqual.d.ts +28 -0
  64. package/module/Validate/isDeepEqual.js +148 -0
  65. package/module/Validate/isDeepEqual.js.map +1 -0
  66. package/module/Validate/isNode.js +3 -2
  67. package/module/Validate/isNode.js.map +1 -1
  68. package/module/Validate/string/email.js +8 -0
  69. package/module/Validate/string/email.js.map +1 -1
  70. package/module/es5/Crypto/decodeBase32.d.ts +7 -0
  71. package/module/es5/Crypto/decodeBase32.js +44 -0
  72. package/module/es5/Crypto/decodeBase32ToString.d.ts +7 -0
  73. package/module/es5/Crypto/decodeBase32ToString.js +16 -0
  74. package/module/es5/Crypto/decodeBase58.d.ts +7 -0
  75. package/module/es5/Crypto/decodeBase58.js +63 -0
  76. package/module/es5/Crypto/decodeBase58ToString.d.ts +7 -0
  77. package/module/es5/Crypto/decodeBase58ToString.js +16 -0
  78. package/module/es5/Crypto/encodeBase32.d.ts +7 -0
  79. package/module/es5/Crypto/encodeBase32.js +45 -0
  80. package/module/es5/Crypto/encodeBase58.d.ts +7 -0
  81. package/module/es5/Crypto/encodeBase58.js +55 -0
  82. package/module/es5/Crypto/index.d.ts +6 -0
  83. package/module/es5/Crypto/index.js +71 -0
  84. package/module/es5/DataStructure/index.d.ts +1 -0
  85. package/module/es5/DataStructure/index.js +16 -0
  86. package/module/es5/DataStructure/priorityQueue.d.ts +241 -0
  87. package/module/es5/DataStructure/priorityQueue.js +405 -0
  88. package/module/es5/Error/retry.js +2 -2
  89. package/module/es5/Math/correlationCoefficient.d.ts +11 -0
  90. package/module/es5/Math/correlationCoefficient.js +63 -0
  91. package/module/es5/Math/index.d.ts +3 -0
  92. package/module/es5/Math/index.js +33 -0
  93. package/module/es5/Math/mode.d.ts +10 -0
  94. package/module/es5/Math/mode.js +67 -0
  95. package/module/es5/Math/percentile.d.ts +11 -0
  96. package/module/es5/Math/percentile.js +42 -0
  97. package/module/es5/Math/solveEquation.js +1 -1
  98. package/module/es5/String/fuzzySearch.d.ts +14 -0
  99. package/module/es5/String/fuzzySearch.js +50 -0
  100. package/module/es5/String/index.d.ts +4 -0
  101. package/module/es5/String/index.js +44 -0
  102. package/module/es5/String/reverseString.js +1 -1
  103. package/module/es5/String/slugify.d.ts +10 -0
  104. package/module/es5/String/slugify.js +18 -0
  105. package/module/es5/String/truncate.d.ts +12 -0
  106. package/module/es5/String/truncate.js +27 -0
  107. package/module/es5/String/unescapeHtml.d.ts +17 -0
  108. package/module/es5/String/unescapeHtml.js +51 -0
  109. package/module/es5/Validate/index.d.ts +1 -0
  110. package/module/es5/Validate/index.js +11 -0
  111. package/module/es5/Validate/isDeepEqual.d.ts +28 -0
  112. package/module/es5/Validate/isDeepEqual.js +232 -0
  113. package/module/es5/Validate/isNode.js +5 -2
  114. package/module/es5/Validate/string/email.js +10 -0
  115. package/module/es5/index.d.ts +2 -0
  116. package/module/es5/index.js +22 -0
  117. package/module/es5/tsconfig.tsbuildinfo +1 -1
  118. package/module/index.d.ts +2 -0
  119. package/module/index.js +2 -0
  120. package/module/index.js.map +1 -1
  121. package/package.json +31 -31
@@ -0,0 +1,327 @@
1
+ /**
2
+ * A priority queue implementation using a binary heap.
3
+ * Higher priority values are dequeued first.
4
+ *
5
+ * ## Features
6
+ * - **enqueue(value, priority)**: Add element with priority
7
+ * - **enqueueBack(value)**: Add element to the back with lowest priority
8
+ * - **dequeue()**: Remove and return highest priority element
9
+ * - **peek()**: View highest priority element without removing
10
+ * - **peekPriority()**: View highest priority value
11
+ * - **size**: Get number of elements
12
+ * - **isEmpty**: Check if queue is empty
13
+ * - **clear()**: Remove all elements
14
+ * - **toArray()**: Get all elements as array
15
+ * - **toArrayWithPriorities()**: Get all elements with priorities
16
+ *
17
+ * ## Time Complexity
18
+ * - enqueue: O(log n)
19
+ * - enqueueBack: O(log n)
20
+ * - dequeue: O(log n)
21
+ * - peek: O(1)
22
+ * - peekPriority: O(1)
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const queue = new PriorityQueue<string>();
27
+ * queue.enqueue("low", 1);
28
+ * queue.enqueue("high", 3);
29
+ * queue.enqueue("medium", 2);
30
+ *
31
+ * console.log(queue.dequeue()); // "high"
32
+ * console.log(queue.dequeue()); // "medium"
33
+ * console.log(queue.dequeue()); // "low"
34
+ * ```
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * // Initialize with elements
39
+ * const queue = new PriorityQueue([
40
+ * { value: "task1", priority: 1 },
41
+ * { value: "task2", priority: 3 },
42
+ * { value: "task3", priority: 2 }
43
+ * ]);
44
+ *
45
+ * console.log(queue.peek()); // "task2"
46
+ * console.log(queue.peekPriority()); // 3
47
+ * ```
48
+ *
49
+ * @template T - The type of elements stored in the queue
50
+ */
51
+ export class PriorityQueue {
52
+ heap = [];
53
+ minPriority = 0;
54
+ /**
55
+ * Creates a new PriorityQueue instance.
56
+ * @param initialElements - Optional array of initial elements with priorities
57
+ * @example
58
+ * ```typescript
59
+ * const queue = new PriorityQueue<string>();
60
+ * // or
61
+ * const queue = new PriorityQueue([
62
+ * { value: "item1", priority: 10 },
63
+ * { value: "item2", priority: 5 }
64
+ * ]);
65
+ * ```
66
+ */
67
+ constructor(initialElements) {
68
+ if (initialElements) {
69
+ this.heap = [...initialElements];
70
+ this.updateMinPriority();
71
+ this.buildHeap();
72
+ }
73
+ }
74
+ /**
75
+ * Returns the number of elements in the queue.
76
+ * @returns The number of elements in the queue
77
+ * @example
78
+ * ```typescript
79
+ * const queue = new PriorityQueue<string>();
80
+ * queue.enqueue("item", 1);
81
+ * console.log(queue.size); // 1
82
+ * ```
83
+ */
84
+ get size() {
85
+ return this.heap.length;
86
+ }
87
+ /**
88
+ * Checks if the queue is empty.
89
+ * @returns True if the queue is empty, false otherwise
90
+ * @example
91
+ * ```typescript
92
+ * const queue = new PriorityQueue<string>();
93
+ * console.log(queue.isEmpty); // true
94
+ * queue.enqueue("item", 1);
95
+ * console.log(queue.isEmpty); // false
96
+ * ```
97
+ */
98
+ get isEmpty() {
99
+ return this.heap.length === 0;
100
+ }
101
+ /**
102
+ * Adds an element to the queue with a specified priority.
103
+ * Higher priority values are dequeued first.
104
+ * @param value - The value to add
105
+ * @param priority - The priority value (higher values have higher priority)
106
+ * @example
107
+ * ```typescript
108
+ * const queue = new PriorityQueue<string>();
109
+ * queue.enqueue("low", 1);
110
+ * queue.enqueue("high", 10);
111
+ * queue.enqueue("medium", 5);
112
+ * console.log(queue.dequeue()); // "high"
113
+ * ```
114
+ */
115
+ enqueue(value, priority) {
116
+ this.heap.push({ value, priority });
117
+ this.updateMinPriorityOnAdd(priority);
118
+ this.heapifyUp(this.heap.length - 1);
119
+ }
120
+ /**
121
+ * Adds an element to the end of the queue with lowest priority.
122
+ * This element will be dequeued last (FIFO for equal lowest priority).
123
+ *
124
+ * @param value - The value to add
125
+ * @example
126
+ * ```typescript
127
+ * const queue = new PriorityQueue<string>();
128
+ * queue.enqueue("high", 10);
129
+ * queue.enqueue("medium", 5);
130
+ * queue.enqueueBack("back1");
131
+ * queue.enqueueBack("back2");
132
+ * console.log(queue.dequeue()); // "high"
133
+ * console.log(queue.dequeue()); // "medium"
134
+ * console.log(queue.dequeue()); // "back1"
135
+ * console.log(queue.dequeue()); // "back2"
136
+ * ```
137
+ */
138
+ enqueueBack(value) {
139
+ const newPriority = this.minPriority - 1;
140
+ this.heap.push({ value, priority: newPriority });
141
+ this.minPriority = newPriority;
142
+ this.heapifyUp(this.heap.length - 1);
143
+ }
144
+ /**
145
+ * Removes and returns the element with the highest priority.
146
+ * @returns The element with highest priority, or undefined if queue is empty
147
+ * @example
148
+ * ```typescript
149
+ * const queue = new PriorityQueue<string>();
150
+ * queue.enqueue("low", 1);
151
+ * queue.enqueue("high", 10);
152
+ * console.log(queue.dequeue()); // "high"
153
+ * console.log(queue.dequeue()); // "low"
154
+ * console.log(queue.dequeue()); // undefined
155
+ * ```
156
+ */
157
+ dequeue() {
158
+ if (this.heap.length === 0) {
159
+ return;
160
+ }
161
+ if (this.heap.length === 1) {
162
+ return this.heap.pop()?.value;
163
+ }
164
+ const result = this.heap[0].value;
165
+ // biome-ignore lint/style/noNonNullAssertion: pop() cannot return undefined when heap.length > 1
166
+ this.heap[0] = this.heap.pop();
167
+ this.heapifyDown(0);
168
+ return result;
169
+ }
170
+ /**
171
+ * Returns the element with the highest priority without removing it.
172
+ * @returns The element with highest priority, or undefined if queue is empty
173
+ * @example
174
+ * ```typescript
175
+ * const queue = new PriorityQueue<string>();
176
+ * queue.enqueue("low", 1);
177
+ * queue.enqueue("high", 10);
178
+ * console.log(queue.peek()); // "high"
179
+ * console.log(queue.size); // 2 (element not removed)
180
+ * ```
181
+ */
182
+ peek() {
183
+ return this.heap[0]?.value;
184
+ }
185
+ /**
186
+ * Returns the priority of the element with the highest priority.
187
+ * @returns The highest priority value, or undefined if queue is empty
188
+ * @example
189
+ * ```typescript
190
+ * const queue = new PriorityQueue<string>();
191
+ * queue.enqueue("low", 1);
192
+ * queue.enqueue("high", 10);
193
+ * console.log(queue.peekPriority()); // 10
194
+ * ```
195
+ */
196
+ peekPriority() {
197
+ return this.heap[0]?.priority;
198
+ }
199
+ /**
200
+ * Removes all elements from the queue.
201
+ * @example
202
+ * ```typescript
203
+ * const queue = new PriorityQueue<string>();
204
+ * queue.enqueue("item1", 1);
205
+ * queue.enqueue("item2", 2);
206
+ * console.log(queue.size); // 2
207
+ * queue.clear();
208
+ * console.log(queue.size); // 0
209
+ * console.log(queue.isEmpty); // true
210
+ * ```
211
+ */
212
+ clear() {
213
+ this.heap = [];
214
+ this.minPriority = 0;
215
+ }
216
+ /**
217
+ * Returns an array of all elements in the queue (without removing them).
218
+ * The order is not guaranteed to be sorted by priority.
219
+ * @returns Array of all elements in the queue
220
+ * @example
221
+ * ```typescript
222
+ * const queue = new PriorityQueue<string>();
223
+ * queue.enqueue("low", 1);
224
+ * queue.enqueue("high", 10);
225
+ * queue.enqueue("medium", 5);
226
+ * console.log(queue.toArray()); // ["high", "medium", "low"] (order may vary)
227
+ * ```
228
+ */
229
+ toArray() {
230
+ return this.heap.map((item) => item.value);
231
+ }
232
+ /**
233
+ * Returns an array of all elements with their priorities.
234
+ * The order is not guaranteed to be sorted by priority.
235
+ * @returns Array of all elements with their priorities
236
+ * @example
237
+ * ```typescript
238
+ * const queue = new PriorityQueue<string>();
239
+ * queue.enqueue("low", 1);
240
+ * queue.enqueue("high", 10);
241
+ * console.log(queue.toArrayWithPriorities());
242
+ * // [{ value: "high", priority: 10 }, { value: "low", priority: 1 }] (order may vary)
243
+ * ```
244
+ */
245
+ toArrayWithPriorities() {
246
+ return [...this.heap];
247
+ }
248
+ /**
249
+ * Updates the minimum priority when adding elements.
250
+ * @param priority - The priority being added
251
+ */
252
+ updateMinPriorityOnAdd(priority) {
253
+ if (this.heap.length === 1 || priority < this.minPriority) {
254
+ this.minPriority = priority;
255
+ }
256
+ }
257
+ /**
258
+ * Updates the minimum priority from all elements (used in constructor).
259
+ */
260
+ updateMinPriority() {
261
+ if (this.heap.length === 0) {
262
+ this.minPriority = 0;
263
+ return;
264
+ }
265
+ this.minPriority = Math.min(...this.heap.map((item) => item.priority));
266
+ }
267
+ /**
268
+ * Builds a max heap from the current heap array.
269
+ */
270
+ buildHeap() {
271
+ for (let index = Math.floor(this.heap.length / 2) - 1; index >= 0; index--) {
272
+ this.heapifyDown(index);
273
+ }
274
+ }
275
+ /**
276
+ * Moves an element up the heap to maintain heap property.
277
+ * @param index - The index of the element to move up
278
+ */
279
+ heapifyUp(index) {
280
+ let currentIndex = index;
281
+ while (currentIndex > 0) {
282
+ const parentIndex = Math.floor((currentIndex - 1) / 2);
283
+ if (this.heap[currentIndex].priority <= this.heap[parentIndex].priority) {
284
+ break;
285
+ }
286
+ this.swap(currentIndex, parentIndex);
287
+ currentIndex = parentIndex;
288
+ }
289
+ }
290
+ /**
291
+ * Moves an element down the heap to maintain heap property.
292
+ * @param index - The index of the element to move down
293
+ */
294
+ heapifyDown(index) {
295
+ let currentIndex = index;
296
+ while (true) {
297
+ const leftChild = 2 * currentIndex + 1;
298
+ const rightChild = 2 * currentIndex + 2;
299
+ let largest = currentIndex;
300
+ if (leftChild < this.heap.length &&
301
+ this.heap[leftChild].priority > this.heap[largest].priority) {
302
+ largest = leftChild;
303
+ }
304
+ if (rightChild < this.heap.length &&
305
+ this.heap[rightChild].priority > this.heap[largest].priority) {
306
+ largest = rightChild;
307
+ }
308
+ if (largest === currentIndex) {
309
+ break;
310
+ }
311
+ this.swap(currentIndex, largest);
312
+ currentIndex = largest;
313
+ }
314
+ }
315
+ /**
316
+ * Swaps two elements in the heap.
317
+ * @param i - First index
318
+ * @param j - Second index
319
+ */
320
+ swap(index, index_) {
321
+ [this.heap[index], this.heap[index_]] = [
322
+ this.heap[index_],
323
+ this.heap[index],
324
+ ];
325
+ }
326
+ }
327
+ //# sourceMappingURL=priorityQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"priorityQ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efficient between two arrays
3
+ * @param x - First array of numbers
4
+ * @param y - Second array of numbers
5
+ * @returns Correlation coefficient (-1 to 1)
6
+ * @example
7
+ * correlationCoefficient([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
8
+ * correlationCoefficient([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]); // -1 (perfect negative correlation)
9
+ * correlationCoefficient([1, 2, 3, 4, 5], [1, 1, 1, 1, 1]); // 0 (no correlation)
10
+ */
11
+ export declare const correlationCoefficient: (x: number[], y: number[]) => number;
@@ -0,0 +1,40 @@
1
+ import { average } from "./average";
2
+ /**
3
+ * Calculate the Pearson correlation coefficient between two arrays
4
+ * @param x - First array of numbers
5
+ * @param y - Second array of numbers
6
+ * @returns Correlation coefficient (-1 to 1)
7
+ * @example
8
+ * correlationCoefficient([1, 2, 3, 4, 5], [2, 4, 6, 8, 10]); // 1 (perfect positive correlation)
9
+ * correlationCoefficient([1, 2, 3, 4, 5], [5, 4, 3, 2, 1]); // -1 (perfect negative correlation)
10
+ * correlationCoefficient([1, 2, 3, 4, 5], [1, 1, 1, 1, 1]); // 0 (no correlation)
11
+ */
12
+ export const correlationCoefficient = (x, y) => {
13
+ if (x.length !== y.length) {
14
+ throw new Error("Arrays must have the same length");
15
+ }
16
+ if (x.length === 0) {
17
+ return Number.NaN;
18
+ }
19
+ if (x.length === 1) {
20
+ return Number.NaN;
21
+ }
22
+ const meanX = average(x);
23
+ const meanY = average(y);
24
+ let numerator = 0;
25
+ let sumSquaredX = 0;
26
+ let sumSquaredY = 0;
27
+ for (const [index, element] of x.entries()) {
28
+ const deltaX = element - meanX;
29
+ const deltaY = y[index] - meanY;
30
+ numerator += deltaX * deltaY;
31
+ sumSquaredX += deltaX * deltaX;
32
+ sumSquaredY += deltaY * deltaY;
33
+ }
34
+ const denominator = Math.sqrt(sumSquaredX * sumSquaredY);
35
+ if (denominator === 0) {
36
+ return Number.NaN;
37
+ }
38
+ return numerator / denominator;
39
+ };
40
+ //# sourceMappingURL=correlationCoefficient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlationCoefficient.js","sourceRoot":"","sources":["../../src/Math/correlationCoefficient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAW,EAAE,CAAW,EAAU,EAAE;IACzE,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAEzB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC;QAC/B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAEhC,SAAS,IAAI,MAAM,GAAG,MAAM,CAAC;QAC7B,WAAW,IAAI,MAAM,GAAG,MAAM,CAAC;QAC/B,WAAW,IAAI,MAAM,GAAG,MAAM,CAAC;IACjC,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,CAAC;IAEzD,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,OAAO,SAAS,GAAG,WAAW,CAAC;AACjC,CAAC,CAAC"}
@@ -2,6 +2,7 @@ export * from "./addition";
2
2
  export * from "./average";
3
3
  export * from "./bitwise";
4
4
  export * from "./calculator";
5
+ export * from "./correlationCoefficient";
5
6
  export * from "./degToRad";
6
7
  export * from "./deviationValue";
7
8
  export * from "./division";
@@ -17,11 +18,13 @@ export * from "./mathSeparator";
17
18
  export * from "./max";
18
19
  export * from "./median";
19
20
  export * from "./min";
21
+ export * from "./mode";
20
22
  export * from "./multiples";
21
23
  export * from "./multiplication";
22
24
  export * from "./nCr";
23
25
  export * from "./nHr";
24
26
  export * from "./nPr";
27
+ export * from "./percentile";
25
28
  export * from "./primeFactorization";
26
29
  export * from "./quotient";
27
30
  export * from "./radToDeg";
@@ -2,6 +2,7 @@ export * from "./addition";
2
2
  export * from "./average";
3
3
  export * from "./bitwise";
4
4
  export * from "./calculator";
5
+ export * from "./correlationCoefficient";
5
6
  export * from "./degToRad";
6
7
  export * from "./deviationValue";
7
8
  export * from "./division";
@@ -17,11 +18,13 @@ export * from "./mathSeparator";
17
18
  export * from "./max";
18
19
  export * from "./median";
19
20
  export * from "./min";
21
+ export * from "./mode";
20
22
  export * from "./multiples";
21
23
  export * from "./multiplication";
22
24
  export * from "./nCr";
23
25
  export * from "./nHr";
24
26
  export * from "./nPr";
27
+ export * from "./percentile";
25
28
  export * from "./primeFactorization";
26
29
  export * from "./quotient";
27
30
  export * from "./radToDeg";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Math/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,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C3C,cAAc,OAAO,CAAC;AACtB,cAAc,oBAAoB,CAAC;AACnC,cAAc,OAAO,CAAC;AACtB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Finds the most frequently occurring value(s) in an array
3
+ * @param array - Array of numbers to find mode for
4
+ * @returns Array of mode values (can be multiple values if there are ties)
5
+ * @example
6
+ * mode([1, 2, 2, 3, 3, 3]); // [3]
7
+ * mode([1, 2, 2, 3, 3]); // [2, 3]
8
+ * mode([1, 2, 3]); // [1, 2, 3]
9
+ */
10
+ export declare const mode: (array: number[]) => number[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Finds the most frequently occurring value(s) in an array
3
+ * @param array - Array of numbers to find mode for
4
+ * @returns Array of mode values (can be multiple values if there are ties)
5
+ * @example
6
+ * mode([1, 2, 2, 3, 3, 3]); // [3]
7
+ * mode([1, 2, 2, 3, 3]); // [2, 3]
8
+ * mode([1, 2, 3]); // [1, 2, 3]
9
+ */
10
+ export const mode = (array) => {
11
+ if (array.length === 0) {
12
+ return [];
13
+ }
14
+ const frequency = new Map();
15
+ let maxFrequency = 0;
16
+ // Count frequencies
17
+ for (const value of array) {
18
+ const count = (frequency.get(value) || 0) + 1;
19
+ frequency.set(value, count);
20
+ maxFrequency = Math.max(maxFrequency, count);
21
+ }
22
+ // Find all values with maximum frequency
23
+ const modes = [];
24
+ for (const [value, count] of frequency) {
25
+ if (count === maxFrequency) {
26
+ modes.push(value);
27
+ }
28
+ }
29
+ return modes.sort((a, b) => a - b);
30
+ };
31
+ //# sourceMappingURL=mode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mode.js","sourceRoot":"","sources":["../../src/Math/mode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAe,EAAY,EAAE;IAChD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC5C,IAAI,YAAY,GAAG,CAAC,CAAC;IAErB,oBAAoB;IACpB,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9C,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC5B,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,yCAAyC;IACzC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,SAAS,EAAE,CAAC;QACvC,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Calculate the nth percentile of values in an array
3
+ * @param array - Array of numbers
4
+ * @param percentile - Percentile value (0-100)
5
+ * @returns The percentile value
6
+ * @example
7
+ * percentile([1, 2, 3, 4, 5], 50); // 3 (50th percentile - median)
8
+ * percentile([1, 2, 3, 4, 5], 25); // 2 (25th percentile)
9
+ * percentile([1, 2, 3, 4, 5], 75); // 4 (75th percentile)
10
+ */
11
+ export declare const percentile: (array: number[], percentile: number) => number;
@@ -0,0 +1,31 @@
1
+ import { quickSort } from "../Array/quickSort";
2
+ /**
3
+ * Calculate the nth percentile of values in an array
4
+ * @param array - Array of numbers
5
+ * @param percentile - Percentile value (0-100)
6
+ * @returns The percentile value
7
+ * @example
8
+ * percentile([1, 2, 3, 4, 5], 50); // 3 (50th percentile - median)
9
+ * percentile([1, 2, 3, 4, 5], 25); // 2 (25th percentile)
10
+ * percentile([1, 2, 3, 4, 5], 75); // 4 (75th percentile)
11
+ */
12
+ export const percentile = (array, percentile) => {
13
+ if (array.length === 0) {
14
+ return Number.NaN;
15
+ }
16
+ if (percentile < 0 || percentile > 100) {
17
+ throw new Error("Percentile must be between 0 and 100");
18
+ }
19
+ const sortedArray = quickSort([...array]);
20
+ const index = (percentile / 100) * (sortedArray.length - 1);
21
+ const lowerIndex = Math.floor(index);
22
+ const upperIndex = Math.ceil(index);
23
+ if (lowerIndex === upperIndex) {
24
+ return sortedArray[lowerIndex];
25
+ }
26
+ const lowerValue = sortedArray[lowerIndex];
27
+ const upperValue = sortedArray[upperIndex];
28
+ const weight = index - lowerIndex;
29
+ return lowerValue + (upperValue - lowerValue) * weight;
30
+ };
31
+ //# sourceMappingURL=percentile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percentile.js","sourceRoot":"","sources":["../../src/Math/percentile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAe,EAAE,UAAkB,EAAU,EAAE;IACxE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,GAAG,GAAG,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAEpC,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;IAElC,OAAO,UAAU,GAAG,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,MAAM,CAAC;AACzD,CAAC,CAAC"}
@@ -60,6 +60,6 @@ export const solveEquation = (coefficients, constants) => {
60
60
  solution.push(division(subtract(constants[row], sum), coefficients[row][row]));
61
61
  }
62
62
  // Return the solution vector with values rounded to 1 decimal place
63
- return solution.reverse().map((value) => roundOf(value, 1));
63
+ return solution.toReversed().map((value) => roundOf(value, 1));
64
64
  };
65
65
  //# sourceMappingURL=solveEquation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"solveEquation.js","sourceRoot":"","sources":["../../src/Math/solveEquation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,YAAwB,EACxB,SAAmB,EACT,EAAE;IACZ,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;IAC3B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACvC,wDAAwD;QACxD,IAAI,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,KAAK,IAAI,GAAG,GAAG,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC;YACzC,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,EAAE,CAAC;gBACpD,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBACh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AAC;QAED,QAAQ,CAAC,IAAI,CACX,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAChE,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,OAAO,QAAQ,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Perform fuzzy string matching on an array of strings
3
+ * @param query - The search query
4
+ * @param items - Array of strings to search in
5
+ * @param threshold - Similarity threshold (0-1) for matching (default: 0.6)
6
+ * @returns Array of matching items with their similarity scores, sorted by best match
7
+ * @example
8
+ * fuzzySearch("hello", ["hello", "world", "helo", "help"]);
9
+ * // [{ item: "hello", score: 1 }, { item: "helo", score: 0.8 }, { item: "help", score: 0.6 }]
10
+ */
11
+ export declare const fuzzySearch: (query: string, items: string[], threshold?: number) => Array<{
12
+ item: string;
13
+ score: number;
14
+ }>;
@@ -0,0 +1,27 @@
1
+ import { levenshteinDistance } from "./levenshteinDistance";
2
+ /**
3
+ * Perform fuzzy string matching on an array of strings
4
+ * @param query - The search query
5
+ * @param items - Array of strings to search in
6
+ * @param threshold - Similarity threshold (0-1) for matching (default: 0.6)
7
+ * @returns Array of matching items with their similarity scores, sorted by best match
8
+ * @example
9
+ * fuzzySearch("hello", ["hello", "world", "helo", "help"]);
10
+ * // [{ item: "hello", score: 1 }, { item: "helo", score: 0.8 }, { item: "help", score: 0.6 }]
11
+ */
12
+ export const fuzzySearch = (query, items, threshold = 0.6) => {
13
+ if (query.length === 0) {
14
+ return [];
15
+ }
16
+ const results = [];
17
+ for (const item of items) {
18
+ const distance = levenshteinDistance(query.toLowerCase(), item.toLowerCase());
19
+ const maxLength = Math.max(query.length, item.length);
20
+ const score = 1 - distance / maxLength;
21
+ if (score >= threshold) {
22
+ results.push({ item, score });
23
+ }
24
+ }
25
+ return results.sort((a, b) => b.score - a.score);
26
+ };
27
+ //# sourceMappingURL=fuzzySearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fuzzySearch.js","sourceRoot":"","sources":["../../src/String/fuzzySearch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAa,EACb,KAAe,EACf,SAAS,GAAG,GAAG,EACyB,EAAE;IAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAA2C,EAAE,CAAC;IAE3D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,mBAAmB,CAClC,KAAK,CAAC,WAAW,EAAE,EACnB,IAAI,CAAC,WAAW,EAAE,CACnB,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACtD,MAAM,KAAK,GAAG,CAAC,GAAG,QAAQ,GAAG,SAAS,CAAC;QAEvC,IAAI,KAAK,IAAI,SAAS,EAAE,CAAC;YACvB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC,CAAC"}
@@ -3,6 +3,7 @@ export * from "./deleteSpaces";
3
3
  export * from "./escapeHtml";
4
4
  export * from "./formatString";
5
5
  export * from "./fromBase64";
6
+ export * from "./fuzzySearch";
6
7
  export * from "./hasNoLetters";
7
8
  export * from "./kebabCase";
8
9
  export * from "./levenshteinDistance";
@@ -11,9 +12,12 @@ export * from "./padStart";
11
12
  export * from "./randomString";
12
13
  export * from "./randomStringInitialization";
13
14
  export * from "./reverseString";
15
+ export * from "./slugify";
14
16
  export * from "./stringSimilarity";
15
17
  export * from "./toBase64";
16
18
  export * from "./toHalfWidth";
17
19
  export * from "./trimCharacters";
18
20
  export * from "./trimEndCharacters";
19
21
  export * from "./trimStartCharacters";
22
+ export * from "./truncate";
23
+ export * from "./unescapeHtml";
@@ -3,6 +3,7 @@ export * from "./deleteSpaces";
3
3
  export * from "./escapeHtml";
4
4
  export * from "./formatString";
5
5
  export * from "./fromBase64";
6
+ export * from "./fuzzySearch";
6
7
  export * from "./hasNoLetters";
7
8
  export * from "./kebabCase";
8
9
  export * from "./levenshteinDistance";
@@ -11,10 +12,13 @@ export * from "./padStart";
11
12
  export * from "./randomString";
12
13
  export * from "./randomStringInitialization";
13
14
  export * from "./reverseString";
15
+ export * from "./slugify";
14
16
  export * from "./stringSimilarity";
15
17
  export * from "./toBase64";
16
18
  export * from "./toHalfWidth";
17
19
  export * from "./trimCharacters";
18
20
  export * from "./trimEndCharacters";
19
21
  export * from "./trimStartCharacters";
22
+ export * from "./truncate";
23
+ export * from "./unescapeHtml";
20
24
  //# sourceMappingURL=index.js.map