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,362 @@
1
+ /**
2
+ * Error thrown when attempting to divide by zero.
3
+ */
4
+ declare class DivisionByZeroError extends Error {
5
+ constructor();
6
+ }
7
+ /**
8
+ * Safely adds two numbers, handling floating-point precision.
9
+ *
10
+ * @param a - First number.
11
+ * @param b - Second number.
12
+ * @returns The sum.
13
+ */
14
+ declare function add(a: number, b: number): number;
15
+ /**
16
+ * Safely subtracts two numbers, handling floating-point precision.
17
+ *
18
+ * @param a - First number.
19
+ * @param b - Second number.
20
+ * @returns The difference.
21
+ */
22
+ declare function sub(a: number, b: number): number;
23
+ /**
24
+ * Safely multiplies two numbers, handling floating-point precision.
25
+ *
26
+ * @param a - First number.
27
+ * @param b - Second number.
28
+ * @returns The product.
29
+ */
30
+ declare function mul(a: number, b: number): number;
31
+ /**
32
+ * Safely divides two numbers.
33
+ *
34
+ * @param a - The dividend.
35
+ * @param b - The divisor.
36
+ * @returns The quotient.
37
+ * @throws {DivisionByZeroError} If `b` is zero.
38
+ */
39
+ declare function div(a: number, b: number): number;
40
+ /**
41
+ * Rounds a number to the given precision.
42
+ *
43
+ * @param value - The number to round.
44
+ * @param precision - Number of decimal places (default 0).
45
+ * @returns The rounded value.
46
+ */
47
+ declare function round(value: number, precision?: number): number;
48
+ /**
49
+ * Floors a number to the given precision.
50
+ *
51
+ * @param value - The number to floor.
52
+ * @param precision - Number of decimal places (default 0).
53
+ * @returns The floored value.
54
+ */
55
+ declare function floor(value: number, precision?: number): number;
56
+ /**
57
+ * Ceils a number to the given precision.
58
+ *
59
+ * @param value - The number to ceil.
60
+ * @param precision - Number of decimal places (default 0).
61
+ * @returns The ceiled value.
62
+ */
63
+ declare function ceil(value: number, precision?: number): number;
64
+ /**
65
+ * Checks if two numbers are approximately equal within a tolerance.
66
+ *
67
+ * @param a - First number.
68
+ * @param b - Second number.
69
+ * @param tolerance - Maximum difference (default `Number.EPSILON`).
70
+ * @returns Whether the numbers are approximately equal.
71
+ */
72
+ declare function approxEqual(a: number, b: number, tolerance?: number): boolean;
73
+ /**
74
+ * Clamps a value within the inclusive range [min, max].
75
+ *
76
+ * @param value - The value to clamp.
77
+ * @param min - The lower bound.
78
+ * @param max - The upper bound.
79
+ * @returns The clamped value.
80
+ * @throws {RangeError} If `min` exceeds `max`.
81
+ */
82
+ declare function clamp(value: number, min: number, max: number): number;
83
+ /**
84
+ * Computes the sum of an array of numbers.
85
+ *
86
+ * @param values - Array of numbers.
87
+ * @returns The total sum.
88
+ */
89
+ declare function sum(values: number[]): number;
90
+ /**
91
+ * Computes the average (mean) of an array of numbers.
92
+ *
93
+ * @param values - Array of numbers.
94
+ * @returns The average.
95
+ * @throws {RangeError} If the array is empty.
96
+ */
97
+ declare function average(values: number[]): number;
98
+ /**
99
+ * Generates a random integer between `min` and `max` (inclusive).
100
+ *
101
+ * @param min - The minimum integer.
102
+ * @param max - The maximum integer.
103
+ * @returns A random integer.
104
+ * @throws {RangeError} If arguments are not integers or `min > max`.
105
+ */
106
+ declare function randomInt(min: number, max: number): number;
107
+ /**
108
+ * Checks if a number is within the inclusive range [min, max].
109
+ *
110
+ * @param value - The number to check.
111
+ * @param min - The lower bound.
112
+ * @param max - The upper bound.
113
+ * @returns Whether the value is in range.
114
+ */
115
+ declare function inRange(value: number, min: number, max: number): boolean;
116
+ /**
117
+ * Computes the median of an array of numbers.
118
+ *
119
+ * @param values - Array of numbers.
120
+ * @returns The median value.
121
+ * @throws {RangeError} If the array is empty.
122
+ */
123
+ declare function median(values: number[]): number;
124
+ /**
125
+ * Computes the population standard deviation.
126
+ *
127
+ * @param values - Array of numbers.
128
+ * @returns The standard deviation.
129
+ * @throws {RangeError} If the array has fewer than 2 values.
130
+ */
131
+ declare function stddev(values: number[]): number;
132
+ /**
133
+ * Computes the sample standard deviation (Bessel's correction).
134
+ *
135
+ * @param values - Array of numbers.
136
+ * @returns The sample standard deviation.
137
+ * @throws {RangeError} If the array has fewer than 2 values.
138
+ */
139
+ declare function sampleStddev(values: number[]): number;
140
+ /**
141
+ * Computes the percentile value (0-100) using linear interpolation.
142
+ *
143
+ * @param values - Array of numbers.
144
+ * @param p - Percentile (0-100).
145
+ * @returns The percentile value.
146
+ * @throws {RangeError} If p is outside [0, 100] or array is empty.
147
+ */
148
+ declare function percentile(values: number[], p: number): number;
149
+ /**
150
+ * Computes the Pearson correlation coefficient between two arrays.
151
+ *
152
+ * @param x - First array.
153
+ * @param y - Second array.
154
+ * @returns The correlation coefficient (-1 to 1).
155
+ * @throws {RangeError} If arrays have different lengths or fewer than 2 pairs.
156
+ */
157
+ declare function correlation(x: number[], y: number[]): number;
158
+ /**
159
+ * Formats a number as a currency string with locale support.
160
+ *
161
+ * @example formatCurrency(1500000) // "Rp1.500.000"
162
+ * @example formatCurrency(1500000, { notation: 'compact' }) // "Rp1,5 jt"
163
+ * @example formatCurrency(99.99, { locale: 'en-US', currency: 'USD' }) // "$99.99"
164
+ *
165
+ * @param value - The number to format.
166
+ * @param options - Formatting options.
167
+ * @returns The formatted currency string.
168
+ */
169
+ declare function formatCurrency(value: number, options?: {
170
+ locale?: string;
171
+ currency?: string;
172
+ notation?: 'standard' | 'compact';
173
+ }): string;
174
+ /**
175
+ * Checks if a number is even.
176
+ *
177
+ * @example isEven(4) // true
178
+ * @example isEven(7) // false
179
+ *
180
+ * @param n - The number to check.
181
+ * @returns Whether the number is even.
182
+ */
183
+ declare function isEven(n: number): boolean;
184
+ /**
185
+ * Checks if a number is odd.
186
+ *
187
+ * @example isOdd(3) // true
188
+ * @example isOdd(8) // false
189
+ *
190
+ * @param n - The number to check.
191
+ * @returns Whether the number is odd.
192
+ */
193
+ declare function isOdd(n: number): boolean;
194
+ /**
195
+ * Computes the greatest common divisor (GCD) using the Euclidean algorithm.
196
+ *
197
+ * @example gcd(12, 8) // 4
198
+ * @example gcd(17, 5) // 1
199
+ *
200
+ * @param a - First integer.
201
+ * @param b - Second integer.
202
+ * @returns The GCD.
203
+ */
204
+ declare function gcd(a: number, b: number): number;
205
+ /**
206
+ * Computes the least common multiple (LCM).
207
+ *
208
+ * @example lcm(4, 6) // 12
209
+ * @example lcm(7, 5) // 35
210
+ *
211
+ * @param a - First integer.
212
+ * @param b - Second integer.
213
+ * @returns The LCM.
214
+ * @throws {RangeError} If either argument is zero.
215
+ */
216
+ declare function lcm(a: number, b: number): number;
217
+ /**
218
+ * Computes the factorial of a non-negative integer.
219
+ *
220
+ * @example factorial(5) // 120
221
+ * @example factorial(0) // 1
222
+ *
223
+ * @param n - Non-negative integer.
224
+ * @returns The factorial.
225
+ * @throws {RangeError} If n is negative or not an integer.
226
+ */
227
+ declare function factorial(n: number): number;
228
+ /**
229
+ * Tests whether a number is prime (optimized trial division).
230
+ *
231
+ * @example isPrime(7) // true
232
+ * @example isPrime(10) // false
233
+ *
234
+ * @param n - Positive integer.
235
+ * @returns Whether the number is prime.
236
+ * @throws {RangeError} If n is not an integer or is less than 2.
237
+ */
238
+ declare function isPrime(n: number): boolean;
239
+ /**
240
+ * Converts degrees to radians.
241
+ *
242
+ * @example toRadians(180) // ~3.14159
243
+ *
244
+ * @param degrees - Angle in degrees.
245
+ * @returns Angle in radians.
246
+ */
247
+ declare function toRadians(degrees: number): number;
248
+ /**
249
+ * Converts radians to degrees.
250
+ *
251
+ * @example toDegrees(Math.PI) // 180
252
+ *
253
+ * @param radians - Angle in radians.
254
+ * @returns Angle in degrees.
255
+ */
256
+ declare function toDegrees(radians: number): number;
257
+ /**
258
+ * Linearly interpolates between `a` and `b` by `t`.
259
+ *
260
+ * @example lerp(0, 100, 0.5) // 50
261
+ *
262
+ * @param a - Start value.
263
+ * @param b - End value.
264
+ * @param t - Interpolation factor (typically 0–1).
265
+ * @returns The interpolated value.
266
+ */
267
+ declare function lerp(a: number, b: number, t: number): number;
268
+ /**
269
+ * Calculates what percentage `value` is of `total`.
270
+ *
271
+ * @example percentageOf(25, 200) // 12.5
272
+ *
273
+ * @param value - The part value.
274
+ * @param total - The total value.
275
+ * @returns The percentage.
276
+ * @throws {RangeError} If total is zero.
277
+ */
278
+ declare function percentageOf(value: number, total: number): number;
279
+ /**
280
+ * Maps a value from one range to another.
281
+ *
282
+ * @example mapRange(0.5, 0, 1, 0, 100) // 50
283
+ *
284
+ * @param value - The value to map.
285
+ * @param inMin - Lower bound of the input range.
286
+ * @param inMax - Upper bound of the input range.
287
+ * @param outMin - Lower bound of the output range.
288
+ * @param outMax - Upper bound of the output range.
289
+ * @returns The mapped value.
290
+ * @throws {RangeError} If the input range is zero.
291
+ */
292
+ declare function mapRange(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
293
+ /**
294
+ * Computes the statistical mode(s) — the most frequently occurring value(s).
295
+ *
296
+ * @example mode([1, 2, 2, 3]) // [2]
297
+ * @example mode([1, 1, 2, 2]) // [1, 2]
298
+ *
299
+ * @param values - Array of numbers.
300
+ * @returns Array of mode value(s).
301
+ * @throws {RangeError} If the array is empty.
302
+ */
303
+ declare function mode(values: number[]): number[];
304
+ /**
305
+ * Generates an array of numbers from `start` to `end` (inclusive),
306
+ * incremented by `step`.
307
+ *
308
+ * @example range(1, 5) // [1, 2, 3, 4, 5]
309
+ * @example range(0, 10, 2) // [0, 2, 4, 6, 8, 10]
310
+ *
311
+ * @param start - Start of the range.
312
+ * @param end - End of the range (inclusive).
313
+ * @param step - Increment (defaults to 1 or -1 based on direction).
314
+ * @returns Array of numbers.
315
+ * @throws {RangeError} If step is zero.
316
+ */
317
+ declare function range(start: number, end: number, step?: number): number[];
318
+ /**
319
+ * Computes the weighted mean of values with corresponding weights.
320
+ *
321
+ * @example weightedAverage([10, 20], [1, 4]) // 18
322
+ *
323
+ * @param values - Array of values.
324
+ * @param weights - Array of weights.
325
+ * @returns The weighted average.
326
+ * @throws {RangeError} If arrays are empty, differ in length, or sum of weights is zero.
327
+ */
328
+ declare function weightedAverage(values: number[], weights: number[]): number;
329
+ /**
330
+ * Computes the geometric mean of an array of numbers.
331
+ *
332
+ * @example geometricMean([4, 9]) // 6
333
+ *
334
+ * @param values - Array of positive numbers.
335
+ * @returns The geometric mean.
336
+ * @throws {RangeError} If the array is empty or contains negative values.
337
+ */
338
+ declare function geometricMean(values: number[]): number;
339
+ /**
340
+ * Computes the number of combinations (n choose k) — selecting k items from n without order.
341
+ *
342
+ * @example combinations(5, 2) // 10
343
+ *
344
+ * @param n - Total items.
345
+ * @param k - Chosen items.
346
+ * @returns The number of combinations.
347
+ * @throws {RangeError} If n < k, or either is negative / non-integer.
348
+ */
349
+ declare function combinations(n: number, k: number): number;
350
+ /**
351
+ * Computes the number of permutations — selecting k items from n in order.
352
+ *
353
+ * @example permutations(5, 2) // 20
354
+ *
355
+ * @param n - Total items.
356
+ * @param k - Chosen items.
357
+ * @returns The number of permutations.
358
+ * @throws {RangeError} If n < k, or either is negative / non-integer.
359
+ */
360
+ declare function permutations(n: number, k: number): number;
361
+
362
+ export { DivisionByZeroError, add, approxEqual, average, ceil, clamp, combinations, correlation, div, factorial, floor, formatCurrency, gcd, geometricMean, inRange, isEven, isOdd, isPrime, lcm, lerp, mapRange, median, mode, mul, percentageOf, percentile, permutations, randomInt, range, round, sampleStddev, stddev, sub, sum, toDegrees, toRadians, weightedAverage };