speexjs-core 0.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 (78) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/CONTRIBUTING.md +55 -0
  3. package/PUBLISH.md +45 -0
  4. package/README.md +174 -0
  5. package/ROADMAP.md +72 -0
  6. package/SECURITY.md +35 -0
  7. package/SUMMARY.md +321 -0
  8. package/dist/async/index.d.ts +232 -0
  9. package/dist/async/index.js +366 -0
  10. package/dist/async/index.js.map +1 -0
  11. package/dist/collection/index.d.ts +230 -0
  12. package/dist/collection/index.js +375 -0
  13. package/dist/collection/index.js.map +1 -0
  14. package/dist/color/index.d.ts +128 -0
  15. package/dist/color/index.js +167 -0
  16. package/dist/color/index.js.map +1 -0
  17. package/dist/core/index.d.ts +119 -0
  18. package/dist/core/index.js +324 -0
  19. package/dist/core/index.js.map +1 -0
  20. package/dist/crypto/index.d.ts +84 -0
  21. package/dist/crypto/index.js +144 -0
  22. package/dist/crypto/index.js.map +1 -0
  23. package/dist/date/index.d.ts +588 -0
  24. package/dist/date/index.js +737 -0
  25. package/dist/date/index.js.map +1 -0
  26. package/dist/dep-exray/analyzer/index.d.ts +7 -0
  27. package/dist/dep-exray/analyzer/index.js +68 -0
  28. package/dist/dep-exray/analyzer/index.js.map +1 -0
  29. package/dist/dep-exray/cli.d.ts +1 -0
  30. package/dist/dep-exray/cli.js +441 -0
  31. package/dist/dep-exray/cli.js.map +1 -0
  32. package/dist/dep-exray/index.d.ts +5 -0
  33. package/dist/dep-exray/index.js +454 -0
  34. package/dist/dep-exray/index.js.map +1 -0
  35. package/dist/dep-exray/known-mappings.d.ts +17 -0
  36. package/dist/dep-exray/known-mappings.js +122 -0
  37. package/dist/dep-exray/known-mappings.js.map +1 -0
  38. package/dist/dep-exray/reporter/index.d.ts +5 -0
  39. package/dist/dep-exray/reporter/index.js +89 -0
  40. package/dist/dep-exray/reporter/index.js.map +1 -0
  41. package/dist/dep-exray/scanner/index.d.ts +5 -0
  42. package/dist/dep-exray/scanner/index.js +299 -0
  43. package/dist/dep-exray/scanner/index.js.map +1 -0
  44. package/dist/dep-exray/types.d.ts +38 -0
  45. package/dist/dep-exray/types.js +1 -0
  46. package/dist/dep-exray/types.js.map +1 -0
  47. package/dist/error/index.d.ts +148 -0
  48. package/dist/error/index.js +115 -0
  49. package/dist/error/index.js.map +1 -0
  50. package/dist/index-BgG21uJC.d.ts +166 -0
  51. package/dist/index.d.ts +19 -0
  52. package/dist/index.js +4378 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/io/index.d.ts +39 -0
  55. package/dist/io/index.js +111 -0
  56. package/dist/io/index.js.map +1 -0
  57. package/dist/logger/index.d.ts +1 -0
  58. package/dist/logger/index.js +214 -0
  59. package/dist/logger/index.js.map +1 -0
  60. package/dist/logger/transports.d.ts +1 -0
  61. package/dist/logger/transports.js +122 -0
  62. package/dist/logger/transports.js.map +1 -0
  63. package/dist/math/index.d.ts +362 -0
  64. package/dist/math/index.js +372 -0
  65. package/dist/math/index.js.map +1 -0
  66. package/dist/path/index.d.ts +81 -0
  67. package/dist/path/index.js +134 -0
  68. package/dist/path/index.js.map +1 -0
  69. package/dist/string/index.d.ts +234 -0
  70. package/dist/string/index.js +411 -0
  71. package/dist/string/index.js.map +1 -0
  72. package/dist/type/index.d.ts +85 -0
  73. package/dist/type/index.js +107 -0
  74. package/dist/type/index.js.map +1 -0
  75. package/dist/validation/index.d.ts +203 -0
  76. package/dist/validation/index.js +402 -0
  77. package/dist/validation/index.js.map +1 -0
  78. package/package.json +172 -0
@@ -0,0 +1,375 @@
1
+ // src/collection/index.ts
2
+ function groupBy(items, keyFn) {
3
+ const result = {};
4
+ for (const item of items) {
5
+ const key = keyFn(item);
6
+ if (!result[key]) result[key] = [];
7
+ result[key].push(item);
8
+ }
9
+ return result;
10
+ }
11
+ function keyBy(items, keyFn) {
12
+ const result = {};
13
+ for (const item of items) {
14
+ const key = keyFn(item);
15
+ result[key] = item;
16
+ }
17
+ return result;
18
+ }
19
+ function omit(obj, keys) {
20
+ const result = { ...obj };
21
+ for (const key of keys) {
22
+ delete result[key];
23
+ }
24
+ return result;
25
+ }
26
+ function pick(obj, keys) {
27
+ const result = {};
28
+ for (const key of keys) {
29
+ if (key in obj) {
30
+ result[key] = obj[key];
31
+ }
32
+ }
33
+ return result;
34
+ }
35
+ function pluck(items, key) {
36
+ return items.map((item) => item[key]);
37
+ }
38
+ function shuffle(items) {
39
+ const result = [...items];
40
+ for (let i = result.length - 1; i > 0; i--) {
41
+ const j = Math.floor(Math.random() * (i + 1));
42
+ const temp = result[i];
43
+ result[i] = result[j];
44
+ result[j] = temp;
45
+ }
46
+ return result;
47
+ }
48
+ function sample(items) {
49
+ return items.length > 0 ? items[Math.floor(Math.random() * items.length)] : void 0;
50
+ }
51
+ function sampleSize(items, size) {
52
+ if (size <= 0 || items.length === 0) return [];
53
+ const pool = shuffle(items);
54
+ return pool.slice(0, Math.min(size, items.length));
55
+ }
56
+ function chunk(items, size) {
57
+ if (size <= 0 || items.length === 0) return [];
58
+ const result = [];
59
+ for (let i = 0; i < items.length; i += size) {
60
+ result.push(items.slice(i, i + size));
61
+ }
62
+ return result;
63
+ }
64
+ function compareValues(a, b) {
65
+ if (a === b) return 0;
66
+ if (a == null) return -1;
67
+ if (b == null) return 1;
68
+ if (typeof a === "string" && typeof b === "string") return a < b ? -1 : 1;
69
+ if (typeof a === "number" && typeof b === "number") return a < b ? -1 : 1;
70
+ return String(a) < String(b) ? -1 : 1;
71
+ }
72
+ function sortBy(items, ...criteria) {
73
+ return [...items].sort((a, b) => {
74
+ for (const criterion of criteria) {
75
+ const cmp = compareValues(criterion(a), criterion(b));
76
+ if (cmp !== 0) return cmp;
77
+ }
78
+ return 0;
79
+ });
80
+ }
81
+ function orderBy(items, key, direction = "asc") {
82
+ return [...items].sort((a, b) => {
83
+ const cmp = compareValues(key(a), key(b));
84
+ return direction === "asc" ? cmp : -cmp;
85
+ });
86
+ }
87
+ function uniqueBy(items, keyFn) {
88
+ const seen = /* @__PURE__ */ new Set();
89
+ return items.filter((item) => {
90
+ const key = keyFn(item);
91
+ if (seen.has(key)) return false;
92
+ seen.add(key);
93
+ return true;
94
+ });
95
+ }
96
+ function flatten(items) {
97
+ const result = [];
98
+ for (const sub of items) {
99
+ for (const item of sub) {
100
+ result.push(item);
101
+ }
102
+ }
103
+ return result;
104
+ }
105
+ function uniq(items) {
106
+ return [...new Set(items)];
107
+ }
108
+ function first(items) {
109
+ return items[0];
110
+ }
111
+ function last(items) {
112
+ return items[items.length - 1];
113
+ }
114
+ function isEmpty(value) {
115
+ if (Array.isArray(value)) return value.length === 0;
116
+ if (typeof value === "string") return value.length === 0;
117
+ if (value instanceof Map || value instanceof Set) return value.size === 0;
118
+ if (value !== null && typeof value === "object") return Object.keys(value).length === 0;
119
+ return false;
120
+ }
121
+ function topoSort(items) {
122
+ const adj = /* @__PURE__ */ new Map();
123
+ const inDegree = /* @__PURE__ */ new Map();
124
+ const itemMap = /* @__PURE__ */ new Map();
125
+ for (const item of items) {
126
+ itemMap.set(item.id, item);
127
+ if (!adj.has(item.id)) adj.set(item.id, []);
128
+ if (!inDegree.has(item.id)) inDegree.set(item.id, 0);
129
+ }
130
+ for (const item of items) {
131
+ if (item.dependencies) {
132
+ for (const depId of item.dependencies) {
133
+ adj.get(depId)?.push(item.id);
134
+ inDegree.set(item.id, (inDegree.get(item.id) ?? 0) + 1);
135
+ }
136
+ }
137
+ }
138
+ const queue = [];
139
+ for (const [id, degree] of inDegree) {
140
+ if (degree === 0) queue.push(id);
141
+ }
142
+ const sorted = [];
143
+ while (queue.length > 0) {
144
+ const id = queue.shift();
145
+ sorted.push(id);
146
+ for (const neighbor of adj.get(id) ?? []) {
147
+ const newDegree = (inDegree.get(neighbor) ?? 1) - 1;
148
+ inDegree.set(neighbor, newDegree);
149
+ if (newDegree === 0) queue.push(neighbor);
150
+ }
151
+ }
152
+ if (sorted.length !== items.length) {
153
+ throw new Error("Circular dependency detected");
154
+ }
155
+ return sorted.map((id) => itemMap.get(id));
156
+ }
157
+ function slidingWindows(items, size, step = 1) {
158
+ if (size <= 0 || items.length === 0 || step <= 0) return [];
159
+ const result = [];
160
+ for (let i = 0; i + size <= items.length; i += step) {
161
+ result.push(items.slice(i, i + size));
162
+ }
163
+ return result;
164
+ }
165
+ function tumblingWindows(items, size) {
166
+ if (size <= 0 || items.length === 0) return [];
167
+ const result = [];
168
+ for (let i = 0; i < items.length; i += size) {
169
+ result.push(items.slice(i, i + size));
170
+ }
171
+ return result;
172
+ }
173
+ function deepGet(obj, path, default_) {
174
+ const keys = path.split(".");
175
+ let current = obj;
176
+ for (const key of keys) {
177
+ if (current === null || current === void 0) return default_;
178
+ if (typeof current !== "object") return default_;
179
+ const curObj = current;
180
+ if (!(key in curObj)) return default_;
181
+ current = curObj[key];
182
+ }
183
+ return current ?? default_;
184
+ }
185
+ function deepSet(obj, path, value) {
186
+ const keys = path.split(".");
187
+ const PROTO_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
188
+ for (const key of keys) {
189
+ if (PROTO_KEYS.has(key)) {
190
+ return { ...obj };
191
+ }
192
+ }
193
+ const result = { ...obj };
194
+ let current = result;
195
+ for (let i = 0; i < keys.length - 1; i++) {
196
+ const key = keys[i];
197
+ const next = current[key];
198
+ if (next === null || next === void 0 || typeof next !== "object") {
199
+ const isArray = /^\d+$/.test(keys[i + 1]);
200
+ current[key] = isArray ? [] : {};
201
+ }
202
+ current = current[key];
203
+ }
204
+ current[keys[keys.length - 1]] = value;
205
+ return result;
206
+ }
207
+ function partition(items, predicate) {
208
+ const pass = [];
209
+ const fail = [];
210
+ for (const item of items) {
211
+ if (predicate(item)) pass.push(item);
212
+ else fail.push(item);
213
+ }
214
+ return [pass, fail];
215
+ }
216
+ function compact(items) {
217
+ return items.filter(Boolean);
218
+ }
219
+ function difference(a, b) {
220
+ const setB = new Set(b);
221
+ return a.filter((item) => !setB.has(item));
222
+ }
223
+ function intersection(a, b) {
224
+ const setB = new Set(b);
225
+ return a.filter((item) => setB.has(item));
226
+ }
227
+ function union(...arrays) {
228
+ const set = /* @__PURE__ */ new Set();
229
+ for (const arr of arrays) {
230
+ for (const item of arr) {
231
+ set.add(item);
232
+ }
233
+ }
234
+ return [...set];
235
+ }
236
+ function zip(...arrays) {
237
+ if (arrays.length === 0) return [];
238
+ const minLen = Math.min(...arrays.map((a) => a.length));
239
+ const result = [];
240
+ for (let i = 0; i < minLen; i++) {
241
+ const tuple = [];
242
+ for (const arr of arrays) {
243
+ tuple.push(arr[i]);
244
+ }
245
+ result.push(tuple);
246
+ }
247
+ return result;
248
+ }
249
+ function unzip(paired) {
250
+ if (paired.length === 0) return [];
251
+ const tupleLen = paired.reduce((max, t) => Math.max(max, t.length), 0);
252
+ const result = Array.from({ length: tupleLen }, () => []);
253
+ for (const tuple of paired) {
254
+ for (let i = 0; i < tupleLen; i++) {
255
+ result[i].push(tuple[i]);
256
+ }
257
+ }
258
+ return result;
259
+ }
260
+ function countBy(items, keyFn) {
261
+ const result = {};
262
+ for (const item of items) {
263
+ const key = keyFn(item);
264
+ result[key] = (result[key] ?? 0) + 1;
265
+ }
266
+ return result;
267
+ }
268
+ function maxBy(items, keyFn) {
269
+ if (items.length === 0) return void 0;
270
+ let maxItem = items[0];
271
+ let maxVal = keyFn(maxItem);
272
+ for (let i = 1; i < items.length; i++) {
273
+ const val = keyFn(items[i]);
274
+ if (val > maxVal) {
275
+ maxVal = val;
276
+ maxItem = items[i];
277
+ }
278
+ }
279
+ return maxItem;
280
+ }
281
+ function minBy(items, keyFn) {
282
+ if (items.length === 0) return void 0;
283
+ let minItem = items[0];
284
+ let minVal = keyFn(minItem);
285
+ for (let i = 1; i < items.length; i++) {
286
+ const val = keyFn(items[i]);
287
+ if (val < minVal) {
288
+ minVal = val;
289
+ minItem = items[i];
290
+ }
291
+ }
292
+ return minItem;
293
+ }
294
+ function sumBy(items, keyFn) {
295
+ let total = 0;
296
+ for (const item of items) {
297
+ total += keyFn(item);
298
+ }
299
+ return total;
300
+ }
301
+ function findIndex(items, predicate, fromIndex = 0) {
302
+ for (let i = fromIndex; i < items.length; i++) {
303
+ if (predicate(items[i])) return i;
304
+ }
305
+ return -1;
306
+ }
307
+ function findLast(items, predicate) {
308
+ for (let i = items.length - 1; i >= 0; i--) {
309
+ if (predicate(items[i])) return items[i];
310
+ }
311
+ return void 0;
312
+ }
313
+ function drop(items, n = 1) {
314
+ return items.slice(Math.max(0, n));
315
+ }
316
+ function dropRight(items, n = 1) {
317
+ return items.slice(0, Math.max(0, items.length - n));
318
+ }
319
+ function take(items, n = 1) {
320
+ return items.slice(0, Math.max(0, n));
321
+ }
322
+ function takeRight(items, n = 1) {
323
+ return items.slice(Math.max(0, items.length - n));
324
+ }
325
+ function without(items, ...values) {
326
+ const exclude = new Set(values);
327
+ return items.filter((item) => !exclude.has(item));
328
+ }
329
+ function nth(items, index) {
330
+ return index < 0 ? items[items.length + index] : items[index];
331
+ }
332
+ export {
333
+ chunk,
334
+ compact,
335
+ countBy,
336
+ deepGet,
337
+ deepSet,
338
+ difference,
339
+ drop,
340
+ dropRight,
341
+ findIndex,
342
+ findLast,
343
+ first,
344
+ flatten,
345
+ groupBy,
346
+ intersection,
347
+ isEmpty,
348
+ keyBy,
349
+ last,
350
+ maxBy,
351
+ minBy,
352
+ nth,
353
+ omit,
354
+ orderBy,
355
+ partition,
356
+ pick,
357
+ pluck,
358
+ sample,
359
+ sampleSize,
360
+ shuffle,
361
+ slidingWindows,
362
+ sortBy,
363
+ sumBy,
364
+ take,
365
+ takeRight,
366
+ topoSort,
367
+ tumblingWindows,
368
+ union,
369
+ uniq,
370
+ uniqueBy,
371
+ unzip,
372
+ without,
373
+ zip
374
+ };
375
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/collection/index.ts"],"sourcesContent":["/**\r\n * Groups an array of items by a key extracted from each item.\r\n *\r\n * @example groupBy([{ type: 'a' }, { type: 'b' }, { type: 'a' }], x => x.type)\r\n * // => { a: [{ type: 'a' }, { type: 'a' }], b: [{ type: 'b' }] }\r\n */\r\nexport function groupBy<T, K extends string | number | symbol>(items: T[], keyFn: (item: T) => K): Record<K, T[]> {\r\n const result = {} as Record<K, T[]>\r\n for (const item of items) {\r\n const key = keyFn(item)\r\n if (!result[key]) result[key] = []\r\n result[key]!.push(item)\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Creates an object keyed by the result of keyFn for each item.\r\n *\r\n * @example keyBy([{ id: 1, name: 'a' }, { id: 2, name: 'b' }], x => x.id)\r\n * // => { 1: { id: 1, name: 'a' }, 2: { id: 2, name: 'b' } }\r\n */\r\nexport function keyBy<T, K extends string | number | symbol>(items: T[], keyFn: (item: T) => K): Record<K, T> {\r\n const result = {} as Record<K, T>\r\n for (const item of items) {\r\n const key = keyFn(item)\r\n result[key] = item\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Returns a copy of the object with the specified keys omitted.\r\n */\r\nexport function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {\r\n const result = { ...obj } as T\r\n for (const key of keys) {\r\n delete result[key]\r\n }\r\n return result as Omit<T, K>\r\n}\r\n\r\n/**\r\n * Returns a copy of the object with only the specified keys.\r\n */\r\nexport function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {\r\n const result = {} as Pick<T, K>\r\n for (const key of keys) {\r\n if (key in obj) {\r\n result[key] = obj[key]\r\n }\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Extracts a property value from each item in an array.\r\n */\r\nexport function pluck<T, K extends keyof T>(items: T[], key: K): T[K][] {\r\n return items.map(item => item[key])\r\n}\r\n\r\n/**\r\n * Randomizes array order in-place using the Fisher-Yates algorithm.\r\n */\r\nexport function shuffle<T>(items: T[]): T[] {\r\n const result = [...items]\r\n for (let i = result.length - 1; i > 0; i--) {\r\n const j = Math.floor(Math.random() * (i + 1))\r\n const temp = result[i]!\r\n result[i] = result[j]!\r\n result[j] = temp\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Returns a random element from the array, or undefined if empty.\r\n */\r\nexport function sample<T>(items: T[]): T | undefined {\r\n return items.length > 0 ? items[Math.floor(Math.random() * items.length)] : undefined\r\n}\r\n\r\n/**\r\n * Returns an array of `size` random elements (without duplicates).\r\n */\r\nexport function sampleSize<T>(items: T[], size: number): T[] {\r\n if (size <= 0 || items.length === 0) return []\r\n const pool = shuffle(items)\r\n return pool.slice(0, Math.min(size, items.length))\r\n}\r\n\r\n/**\r\n * Splits an array into chunks of the specified size.\r\n */\r\nexport function chunk<T>(items: T[], size: number): T[][] {\r\n if (size <= 0 || items.length === 0) return []\r\n const result: T[][] = []\r\n for (let i = 0; i < items.length; i += size) {\r\n result.push(items.slice(i, i + size))\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Returns a sorted copy of the array using the provided criteria functions.\r\n * Earlier criteria take precedence.\r\n */\r\nfunction compareValues(a: unknown, b: unknown): number {\r\n if (a === b) return 0\r\n if (a == null) return -1\r\n if (b == null) return 1\r\n if (typeof a === 'string' && typeof b === 'string') return a < b ? -1 : 1\r\n if (typeof a === 'number' && typeof b === 'number') return a < b ? -1 : 1\r\n return String(a) < String(b) ? -1 : 1\r\n}\r\n\r\nexport function sortBy<T>(items: T[], ...criteria: Array<(item: T) => unknown>): T[] {\r\n return [...items].sort((a, b) => {\r\n for (const criterion of criteria) {\r\n const cmp = compareValues(criterion(a), criterion(b))\r\n if (cmp !== 0) return cmp\r\n }\r\n return 0\r\n })\r\n}\r\n\r\n/**\r\n * Returns a sorted copy of the array by a single key and direction.\r\n */\r\nexport function orderBy<T>(items: T[], key: (item: T) => unknown, direction: SortDirection = 'asc'): T[] {\r\n return [...items].sort((a, b) => {\r\n const cmp = compareValues(key(a), key(b))\r\n return direction === 'asc' ? cmp : -cmp\r\n })\r\n}\r\n\r\n/**\r\n * Returns unique elements based on the result of keyFn.\r\n */\r\nexport function uniqueBy<T>(items: T[], keyFn: (item: T) => unknown): T[] {\r\n const seen = new Set<unknown>()\r\n return items.filter(item => {\r\n const key = keyFn(item)\r\n if (seen.has(key)) return false\r\n seen.add(key)\r\n return true\r\n })\r\n}\r\n\r\n/**\r\n * Flattens an array of arrays one level.\r\n */\r\nexport function flatten<T>(items: T[][]): T[] {\r\n const result: T[] = []\r\n for (const sub of items) {\r\n for (const item of sub) {\r\n result.push(item)\r\n }\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Returns an array with unique primitive values.\r\n */\r\nexport function uniq<T>(items: T[]): T[] {\r\n return [...new Set(items)]\r\n}\r\n\r\n/**\r\n * Returns the first element, or undefined if empty.\r\n */\r\nexport function first<T>(items: T[]): T | undefined {\r\n return items[0]\r\n}\r\n\r\n/**\r\n * Returns the last element, or undefined if empty.\r\n */\r\nexport function last<T>(items: T[]): T | undefined {\r\n return items[items.length - 1]\r\n}\r\n\r\n/**\r\n * Checks if a value is empty.\r\n * Works for arrays, objects, strings, Map, and Set.\r\n */\r\nexport function isEmpty(value: unknown): boolean {\r\n if (Array.isArray(value)) return value.length === 0\r\n if (typeof value === 'string') return value.length === 0\r\n if (value instanceof Map || value instanceof Set) return value.size === 0\r\n if (value !== null && typeof value === 'object') return Object.keys(value as Record<string, unknown>).length === 0\r\n return false\r\n}\r\n\r\nexport type SortDirection = 'asc' | 'desc'\r\n\r\nexport function topoSort<T extends { id: string; dependencies?: string[] }>(items: T[]): T[] {\r\n const adj = new Map<string, string[]>()\r\n const inDegree = new Map<string, number>()\r\n const itemMap = new Map<string, T>()\r\n\r\n for (const item of items) {\r\n itemMap.set(item.id, item)\r\n if (!adj.has(item.id)) adj.set(item.id, [])\r\n if (!inDegree.has(item.id)) inDegree.set(item.id, 0)\r\n }\r\n\r\n for (const item of items) {\r\n if (item.dependencies) {\r\n for (const depId of item.dependencies) {\r\n adj.get(depId)?.push(item.id)\r\n inDegree.set(item.id, (inDegree.get(item.id) ?? 0) + 1)\r\n }\r\n }\r\n }\r\n\r\n const queue: string[] = []\r\n for (const [id, degree] of inDegree) {\r\n if (degree === 0) queue.push(id)\r\n }\r\n\r\n const sorted: string[] = []\r\n while (queue.length > 0) {\r\n const id = queue.shift()!\r\n sorted.push(id)\r\n for (const neighbor of adj.get(id) ?? []) {\r\n const newDegree = (inDegree.get(neighbor) ?? 1) - 1\r\n inDegree.set(neighbor, newDegree)\r\n if (newDegree === 0) queue.push(neighbor)\r\n }\r\n }\r\n\r\n if (sorted.length !== items.length) {\r\n throw new Error('Circular dependency detected')\r\n }\r\n\r\n return sorted.map(id => itemMap.get(id)!)\r\n}\r\n\r\nexport function slidingWindows<T>(items: T[], size: number, step: number = 1): T[][] {\r\n if (size <= 0 || items.length === 0 || step <= 0) return []\r\n const result: T[][] = []\r\n for (let i = 0; i + size <= items.length; i += step) {\r\n result.push(items.slice(i, i + size))\r\n }\r\n return result\r\n}\r\n\r\nexport function tumblingWindows<T>(items: T[], size: number): T[][] {\r\n if (size <= 0 || items.length === 0) return []\r\n const result: T[][] = []\r\n for (let i = 0; i < items.length; i += size) {\r\n result.push(items.slice(i, i + size))\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Gets a nested value from an object using a dot-separated path.\r\n *\r\n * @example deepGet({ a: { b: 2 } }, 'a.b') // 2\r\n * @example deepGet({ a: { b: 2 } }, 'a.c') // undefined\r\n */\r\nexport function deepGet<T = unknown>(obj: unknown, path: string, default_?: T): T | undefined {\r\n const keys = path.split('.')\r\n let current: unknown = obj\r\n for (const key of keys) {\r\n if (current === null || current === undefined) return default_\r\n if (typeof current !== 'object') return default_\r\n const curObj = current as Record<string, unknown>\r\n if (!(key in curObj)) return default_\r\n current = curObj[key]\r\n }\r\n return (current as T) ?? default_\r\n}\r\n\r\n/**\r\n * Sets a nested value in an object using a dot-separated path.\r\n * Creates intermediate objects/arrays as needed.\r\n *\r\n * @example deepSet({ a: { b: 2 } }, 'a.b', 3) // { a: { b: 3 } }\r\n * @example deepSet({}, 'a.b.c', 1) // { a: { b: { c: 1 } } }\r\n */\r\nexport function deepSet<T extends Record<string, unknown>>(obj: T, path: string, value: unknown): T {\r\n const keys = path.split('.')\r\n const PROTO_KEYS = new Set(['__proto__', 'constructor', 'prototype'])\r\n for (const key of keys) {\r\n if (PROTO_KEYS.has(key)) {\r\n return { ...obj } as T\r\n }\r\n }\r\n const result = { ...obj } as Record<string, unknown>\r\n let current = result\r\n for (let i = 0; i < keys.length - 1; i++) {\r\n const key = keys[i]!\r\n const next = current[key]\r\n if (next === null || next === undefined || typeof next !== 'object') {\r\n const isArray = /^\\d+$/.test(keys[i + 1]!)\r\n current[key] = isArray ? [] : {}\r\n }\r\n current = current[key] as Record<string, unknown>\r\n }\r\n current[keys[keys.length - 1]!] = value\r\n return result as T\r\n}\r\n\r\n/**\r\n * Splits an array into two groups: those that pass the predicate and those that don't.\r\n *\r\n * @example partition([1, 2, 3, 4, 5], n => n % 2 === 0)\r\n * // => [[2, 4], [1, 3, 5]]\r\n */\r\nexport function partition<T>(items: T[], predicate: (item: T) => boolean): [T[], T[]] {\r\n const pass: T[] = []\r\n const fail: T[] = []\r\n for (const item of items) {\r\n if (predicate(item)) pass.push(item)\r\n else fail.push(item)\r\n }\r\n return [pass, fail]\r\n}\r\n\r\n/**\r\n * Removes all falsy values from an array (false, null, 0, '', undefined, NaN).\r\n *\r\n * @example compact([0, 1, false, 2, '', 3, null, undefined, NaN])\r\n * // => [1, 2, 3]\r\n */\r\nexport function compact<T>(items: (T | false | null | 0 | '' | undefined)[]): T[] {\r\n return items.filter(Boolean) as T[]\r\n}\r\n\r\n/**\r\n * Returns elements in array A that are not in array B (uses SameValueZero).\r\n *\r\n * @example difference([1, 2, 3, 4], [2, 4])\r\n * // => [1, 3]\r\n */\r\nexport function difference<T>(a: T[], b: T[]): T[] {\r\n const setB = new Set(b)\r\n return a.filter(item => !setB.has(item))\r\n}\r\n\r\n/**\r\n * Returns elements present in all given arrays (uses SameValueZero).\r\n *\r\n * @example intersection([1, 2, 3], [2, 3, 4])\r\n * // => [2, 3]\r\n */\r\nexport function intersection<T>(a: T[], b: T[]): T[] {\r\n const setB = new Set(b)\r\n return a.filter(item => setB.has(item))\r\n}\r\n\r\n/**\r\n * Returns unique elements from all given arrays.\r\n *\r\n * @example union([1, 2], [2, 3], [3, 4])\r\n * // => [1, 2, 3, 4]\r\n */\r\nexport function union<T>(...arrays: T[][]): T[] {\r\n const set = new Set<T>()\r\n for (const arr of arrays) {\r\n for (const item of arr) {\r\n set.add(item)\r\n }\r\n }\r\n return [...set]\r\n}\r\n\r\n/**\r\n * Merges arrays element-wise into tuples, stopping at the shortest array.\r\n *\r\n * @example zip(['a', 'b', 'c'], [1, 2])\r\n * // => [['a', 1], ['b', 2]]\r\n */\r\nexport function zip<T, U>(a: T[], b: U[]): [T, U][]\r\nexport function zip<T, U, V>(a: T[], b: U[], c: V[]): [T, U, V][]\r\nexport function zip<T>(...arrays: T[][]): T[][] {\r\n if (arrays.length === 0) return []\r\n const minLen = Math.min(...arrays.map(a => a.length))\r\n const result: T[][] = []\r\n for (let i = 0; i < minLen; i++) {\r\n const tuple: T[] = []\r\n for (const arr of arrays) {\r\n tuple.push(arr[i]!)\r\n }\r\n result.push(tuple)\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Inverse of zip: splits an array of tuples back into individual arrays.\r\n *\r\n * @example unzip([['a', 1], ['b', 2]])\r\n * // => [['a', 'b'], [1, 2]]\r\n */\r\nexport function unzip<T>(paired: T[][]): T[][] {\r\n if (paired.length === 0) return []\r\n const tupleLen = paired.reduce((max, t) => Math.max(max, t.length), 0)\r\n const result: T[][] = Array.from({ length: tupleLen }, () => [])\r\n for (const tuple of paired) {\r\n for (let i = 0; i < tupleLen; i++) {\r\n result[i]!.push(tuple[i] as T)\r\n }\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Counts occurrences of each key produced by the key function.\r\n *\r\n * @example countBy([1, 2, 3, 4, 5], n => n % 2 === 0 ? 'even' : 'odd')\r\n * // => { odd: 3, even: 2 }\r\n */\r\nexport function countBy<T, K extends string | number | symbol>(items: T[], keyFn: (item: T) => K): Record<K, number> {\r\n const result = {} as Record<K, number>\r\n for (const item of items) {\r\n const key = keyFn(item)\r\n result[key] = (result[key] ?? 0) + 1\r\n }\r\n return result\r\n}\r\n\r\n/**\r\n * Returns the element with the maximum value by the key function.\r\n *\r\n * @example maxBy([{ name: 'a', score: 10 }, { name: 'b', score: 20 }], x => x.score)\r\n * // => { name: 'b', score: 20 }\r\n */\r\nexport function maxBy<T>(items: T[], keyFn: (item: T) => number): T | undefined {\r\n if (items.length === 0) return undefined\r\n let maxItem = items[0]!\r\n let maxVal = keyFn(maxItem)\r\n for (let i = 1; i < items.length; i++) {\r\n const val = keyFn(items[i]!)\r\n if (val > maxVal) {\r\n maxVal = val\r\n maxItem = items[i]!\r\n }\r\n }\r\n return maxItem\r\n}\r\n\r\n/**\r\n * Returns the element with the minimum value by the key function.\r\n *\r\n * @example minBy([{ name: 'a', score: 10 }, { name: 'b', score: 20 }], x => x.score)\r\n * // => { name: 'a', score: 10 }\r\n */\r\nexport function minBy<T>(items: T[], keyFn: (item: T) => number): T | undefined {\r\n if (items.length === 0) return undefined\r\n let minItem = items[0]!\r\n let minVal = keyFn(minItem)\r\n for (let i = 1; i < items.length; i++) {\r\n const val = keyFn(items[i]!)\r\n if (val < minVal) {\r\n minVal = val\r\n minItem = items[i]!\r\n }\r\n }\r\n return minItem\r\n}\r\n\r\n/**\r\n * Returns the sum of values produced by the key function.\r\n *\r\n * @example sumBy([{ n: 1 }, { n: 2 }, { n: 3 }], x => x.n)\r\n * // => 6\r\n */\r\nexport function sumBy<T>(items: T[], keyFn: (item: T) => number): number {\r\n let total = 0\r\n for (const item of items) {\r\n total += keyFn(item)\r\n }\r\n return total\r\n}\r\n\r\n/**\r\n * Returns the index of the first element satisfying the predicate, or -1.\r\n *\r\n * @example findIndex([1, 3, 5, 8, 10], n => n % 2 === 0)\r\n * // => 3\r\n */\r\nexport function findIndex<T>(items: T[], predicate: (item: T) => boolean, fromIndex: number = 0): number {\r\n for (let i = fromIndex; i < items.length; i++) {\r\n if (predicate(items[i]!)) return i\r\n }\r\n return -1\r\n}\r\n\r\n/**\r\n * Finds the last element satisfying the predicate.\r\n *\r\n * @example findLast([1, 2, 3, 4, 5], n => n % 2 === 0)\r\n * // => 4\r\n */\r\nexport function findLast<T>(items: T[], predicate: (item: T) => boolean): T | undefined {\r\n for (let i = items.length - 1; i >= 0; i--) {\r\n if (predicate(items[i]!)) return items[i]\r\n }\r\n return undefined\r\n}\r\n\r\n/**\r\n * Drops the first n elements from the array.\r\n *\r\n * @example drop([1, 2, 3, 4, 5], 2)\r\n * // => [3, 4, 5]\r\n */\r\nexport function drop<T>(items: T[], n: number = 1): T[] {\r\n return items.slice(Math.max(0, n))\r\n}\r\n\r\n/**\r\n * Drops the last n elements from the array.\r\n *\r\n * @example dropRight([1, 2, 3, 4, 5], 2)\r\n * // => [1, 2, 3]\r\n */\r\nexport function dropRight<T>(items: T[], n: number = 1): T[] {\r\n return items.slice(0, Math.max(0, items.length - n))\r\n}\r\n\r\n/**\r\n * Takes the first n elements from the array.\r\n *\r\n * @example take([1, 2, 3, 4, 5], 2)\r\n * // => [1, 2]\r\n */\r\nexport function take<T>(items: T[], n: number = 1): T[] {\r\n return items.slice(0, Math.max(0, n))\r\n}\r\n\r\n/**\r\n * Takes the last n elements from the array.\r\n *\r\n * @example takeRight([1, 2, 3, 4, 5], 2)\r\n * // => [4, 5]\r\n */\r\nexport function takeRight<T>(items: T[], n: number = 1): T[] {\r\n return items.slice(Math.max(0, items.length - n))\r\n}\r\n\r\n/**\r\n * Removes specified values from the array (uses SameValueZero).\r\n *\r\n * @example without([1, 2, 1, 3, 1, 4], 1, 3)\r\n * // => [2, 4]\r\n */\r\nexport function without<T>(items: T[], ...values: T[]): T[] {\r\n const exclude = new Set(values)\r\n return items.filter(item => !exclude.has(item))\r\n}\r\n\r\n/**\r\n * Gets the element at the given index. Supports negative indexing.\r\n *\r\n * @example nth([1, 2, 3], 1) // => 2\r\n * @example nth([1, 2, 3], -1) // => 3\r\n */\r\nexport function nth<T>(items: T[], index: number): T | undefined {\r\n return index < 0 ? items[items.length + index] : items[index]\r\n}\r\n"],"mappings":";AAMO,SAAS,QAA+C,OAAY,OAAuC;AAChH,QAAM,SAAS,CAAC;AAChB,aAAW,QAAQ,OAAO;AACxB,UAAM,MAAM,MAAM,IAAI;AACtB,QAAI,CAAC,OAAO,GAAG,EAAG,QAAO,GAAG,IAAI,CAAC;AACjC,WAAO,GAAG,EAAG,KAAK,IAAI;AAAA,EACxB;AACA,SAAO;AACT;AAQO,SAAS,MAA6C,OAAY,OAAqC;AAC5G,QAAM,SAAS,CAAC;AAChB,aAAW,QAAQ,OAAO;AACxB,UAAM,MAAM,MAAM,IAAI;AACtB,WAAO,GAAG,IAAI;AAAA,EAChB;AACA,SAAO;AACT;AAKO,SAAS,KAA2D,KAAQ,MAAuB;AACxG,QAAM,SAAS,EAAE,GAAG,IAAI;AACxB,aAAW,OAAO,MAAM;AACtB,WAAO,OAAO,GAAG;AAAA,EACnB;AACA,SAAO;AACT;AAKO,SAAS,KAA2D,KAAQ,MAAuB;AACxG,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,MAAM;AACtB,QAAI,OAAO,KAAK;AACd,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;AAKO,SAAS,MAA4B,OAAY,KAAgB;AACtE,SAAO,MAAM,IAAI,UAAQ,KAAK,GAAG,CAAC;AACpC;AAKO,SAAS,QAAW,OAAiB;AAC1C,QAAM,SAAS,CAAC,GAAG,KAAK;AACxB,WAAS,IAAI,OAAO,SAAS,GAAG,IAAI,GAAG,KAAK;AAC1C,UAAM,IAAI,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE;AAC5C,UAAM,OAAO,OAAO,CAAC;AACrB,WAAO,CAAC,IAAI,OAAO,CAAC;AACpB,WAAO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ToRgb('#f00') // { r: 255, g: 0, b: 0 }
6
+ * @example hexToRgb('#FF8800') // { r: 255, g: 136, b: 0 }
7
+ */
8
+ declare function hexToRgb(hex: string): {
9
+ r: number;
10
+ g: number;
11
+ b: number;
12
+ } | null;
13
+ /**
14
+ * Converts RGB values to a hex color string.
15
+ *
16
+ * @example rgbToHex(255, 0, 0) // "#ff0000"
17
+ * @example rgbToHex(255, 136, 0) // "#ff8800"
18
+ */
19
+ declare function rgbToHex(r: number, g: number, b: number): string;
20
+ /**
21
+ * Lightens a hex color by a given percentage (0-100).
22
+ *
23
+ * @example lighten('#ff0000', 20) // "#ff3333"
24
+ * @example lighten('#0000ff', 50) // "#7f7fff"
25
+ */
26
+ declare function lighten(hex: string, percent: number): string;
27
+ /**
28
+ * Darkens a hex color by a given percentage (0-100).
29
+ *
30
+ * @example darken('#ff0000', 20) // "#cc0000"
31
+ * @example darken('#00ff00', 50) // "#008000"
32
+ */
33
+ declare function darken(hex: string, percent: number): string;
34
+ /**
35
+ * Checks the WCAG contrast ratio between two hex colors.
36
+ * Returns the ratio as a number (1-21). WCAG AA requires 4.5:1 for normal text.
37
+ *
38
+ * @example contrastRatio('#000000', '#ffffff') // 21
39
+ * @example contrastRatio('#ff0000', '#ffffff') // 3.99
40
+ */
41
+ declare function contrastRatio(hex1: string, hex2: string): number;
42
+ /**
43
+ * Checks if a hex color meets WCAG AA contrast ratio (4.5:1) against another color.
44
+ *
45
+ * @example meetsWCAG('#000000', '#ffffff') // true (black on white)
46
+ * @example meetsWCAG('#999999', '#ffffff') // false (gray on white)
47
+ */
48
+ declare function meetsWCAG(hex1: string, hex2: string, level?: 'AA' | 'AAA'): boolean;
49
+ /**
50
+ * Checks if a string is a valid hex color.
51
+ * Supports 3-digit (#rgb), 6-digit (#rrggbb), with or without leading `#`.
52
+ *
53
+ * @example isValidHex('#ff0000') // true
54
+ * @example isValidHex('#f00') // true
55
+ * @example isValidHex('ff0000') // true
56
+ * @example isValidHex('#xyz') // false
57
+ */
58
+ declare function isValidHex(value: string): boolean;
59
+ /**
60
+ * Converts a hex color to an HSL object.
61
+ * Returns `null` for invalid input.
62
+ *
63
+ * @example hexToHsl('#ff0000') // { h: 0, s: 100, l: 50 }
64
+ * @example hexToHsl('#00ff00') // { h: 120, s: 100, l: 50 }
65
+ * @example hexToHsl('#0000ff') // { h: 240, s: 100, l: 50 }
66
+ */
67
+ declare function hexToHsl(hex: string): {
68
+ h: number;
69
+ s: number;
70
+ l: number;
71
+ } | null;
72
+ /**
73
+ * Converts HSL values to a hex color string.
74
+ *
75
+ * @example hslToHex(0, 100, 50) // '#ff0000'
76
+ * @example hslToHex(120, 100, 50) // '#00ff00'
77
+ * @example hslToHex(240, 100, 50) // '#0000ff'
78
+ */
79
+ declare function hslToHex(h: number, s: number, l: number): string;
80
+ /**
81
+ * Blends two hex colors together with a weight factor.
82
+ * Weight 0 = fully color1, weight 1 = fully color2. Default 0.5.
83
+ *
84
+ * @example mix('#ff0000', '#0000ff') // '#7f007f'
85
+ * @example mix('#ff0000', '#0000ff', 0) // '#ff0000'
86
+ * @example mix('#ff0000', '#0000ff', 1) // '#0000ff'
87
+ */
88
+ declare function mix(color1: string, color2: string, weight?: number): string;
89
+ /**
90
+ * Generates a random hex color.
91
+ *
92
+ * @example randomColor() // '#a3f07b'
93
+ */
94
+ declare function randomColor(): string;
95
+ /**
96
+ * Checks if a hex color is perceived as light (useful for text contrast decisions).
97
+ *
98
+ * @example isLight('#ffffff') // true
99
+ * @example isLight('#000000') // false
100
+ * @example isLight('#ff0000') // false
101
+ */
102
+ declare function isLight(hex: string): boolean;
103
+ /**
104
+ * Checks if a hex color is perceived as dark.
105
+ *
106
+ * @example isDark('#000000') // true
107
+ * @example isDark('#ffffff') // false
108
+ */
109
+ declare function isDark(hex: string): boolean;
110
+ /**
111
+ * Returns the complementary color (180° hue rotation).
112
+ *
113
+ * @example complementary('#ff0000') // '#00ffff'
114
+ * @example complementary('#00ff00') // '#ff00ff'
115
+ * @example complementary('#0000ff') // '#ffff00'
116
+ */
117
+ declare function complementary(hex: string): string;
118
+ /**
119
+ * Sets opacity on a hex color, returning an 8-digit hex (#rrggbbaa).
120
+ * Opacity is clamped to 0-1.
121
+ *
122
+ * @example alpha('#ff0000', 0.5) // '#ff000080'
123
+ * @example alpha('#00ff00', 1) // '#00ff00ff'
124
+ * @example alpha('#0000ff', 0) // '#0000ff00'
125
+ */
126
+ declare function alpha(hex: string, opacity: number): string;
127
+
128
+ export { alpha, complementary, contrastRatio, darken, hexToHsl, hexToRgb, hslToHex, isDark, isLight, isValidHex, lighten, meetsWCAG, mix, randomColor, rgbToHex };