extra-math 1.3.50 → 1.3.52

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 (3) hide show
  1. package/LICENSE +1 -1
  2. package/index.d.ts +45 -133
  3. package/package.json +7 -7
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018-22 Subhajit Sahu
3
+ Copyright (c) 2018-23 Subhajit Sahu
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/index.d.ts CHANGED
@@ -3,27 +3,21 @@
3
3
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/floor)
4
4
  * @param x a number
5
5
  * @param pre to precision (1)
6
- * */
7
-
8
-
6
+ */
9
7
  declare function floor(x: number, pre?: number): number;
10
8
  /**
11
9
  * Round up a number to specific precision.
12
10
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/ceil)
13
11
  * @param x a number
14
12
  * @param pre to precision [1]
15
- * */
16
-
17
-
13
+ */
18
14
  declare function ceil(x: number, pre?: number): number;
19
15
  /**
20
16
  * Round a number to specific precision.
21
17
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/round)
22
18
  * @param x a number
23
19
  * @param pre to precision [1]
24
- * */
25
-
26
-
20
+ */
27
21
  declare function round(x: number, pre?: number): number;
28
22
  /**
29
23
  * Perform floor-divison of two numbers.
@@ -31,9 +25,7 @@ declare function round(x: number, pre?: number): number;
31
25
  * @param x divisor
32
26
  * @param y dividend
33
27
  * @returns ⌊x/yāŒ‹
34
- * */
35
-
36
-
28
+ */
37
29
  declare function floorDiv(x: number, y: number): number;
38
30
  /**
39
31
  * Perform ceiling-divison of two numbers.
@@ -41,9 +33,7 @@ declare function floorDiv(x: number, y: number): number;
41
33
  * @param x divisor
42
34
  * @param y dividend
43
35
  * @returns ⌈x/yāŒ‰
44
- * */
45
-
46
-
36
+ */
47
37
  declare function ceilDiv(x: number, y: number): number;
48
38
  /**
49
39
  * Perform rounded-divison of two numbers.
@@ -51,9 +41,7 @@ declare function ceilDiv(x: number, y: number): number;
51
41
  * @param x divisor
52
42
  * @param y dividend
53
43
  * @returns [x/y]
54
- * */
55
-
56
-
44
+ */
57
45
  declare function roundDiv(x: number, y: number): number;
58
46
  /**
59
47
  * Find the remainder of x/y with sign of x (truncated division).
@@ -61,9 +49,7 @@ declare function roundDiv(x: number, y: number): number;
61
49
  * @param x dividend
62
50
  * @param y divisor
63
51
  * @returns trunc(x % y)
64
- * */
65
-
66
-
52
+ */
67
53
  declare function rem(x: number, y: number): number;
68
54
  /**
69
55
  * Find the remainder of x/y with sign of y (floored division).
@@ -71,9 +57,7 @@ declare function rem(x: number, y: number): number;
71
57
  * @param x dividend
72
58
  * @param y divisor
73
59
  * @returns floor(x % y)
74
- * */
75
-
76
-
60
+ */
77
61
  declare function mod(x: number, y: number): number;
78
62
  /**
79
63
  * Find the remainder of x/y with +ve sign (euclidean division).
@@ -81,9 +65,7 @@ declare function mod(x: number, y: number): number;
81
65
  * @param x dividend
82
66
  * @param y divisor
83
67
  * @returns n>0: floor(x % y), n<0: ceil(x % y)
84
- * */
85
-
86
-
68
+ */
87
69
  declare function modp(x: number, y: number): number;
88
70
  /**
89
71
  * Constrain a number within a minimum and a maximum value.
@@ -92,9 +74,7 @@ declare function modp(x: number, y: number): number;
92
74
  * @param min minimum value
93
75
  * @param max maximum value
94
76
  * @returns x<min: min, x>max: max, x
95
- * */
96
-
97
-
77
+ */
98
78
  declare function constrain(x: number, min: number, max: number): number;
99
79
 
100
80
  /**
@@ -104,9 +84,7 @@ declare function constrain(x: number, min: number, max: number): number;
104
84
  * @param r lower bound of current range
105
85
  * @param R upper bound of current range
106
86
  * @returns ∈ [0, 1]
107
- * */
108
-
109
-
87
+ */
110
88
  declare function normalize(x: number, r: number, R: number): number;
111
89
 
112
90
  /**
@@ -118,9 +96,7 @@ declare function normalize(x: number, r: number, R: number): number;
118
96
  * @param t lower bound of target range
119
97
  * @param T upper bound of target range
120
98
  * @returns ∈ [ymin, ymax]
121
- * */
122
-
123
-
99
+ */
124
100
  declare function remap(x: number, r: number, R: number, t: number, T: number): number;
125
101
 
126
102
  /**
@@ -130,9 +106,7 @@ declare function remap(x: number, r: number, R: number, t: number, T: number): n
130
106
  * @param y stop number
131
107
  * @param t interpolant ∈ [0, 1]
132
108
  * @returns ∈ [x, y]
133
- * */
134
-
135
-
109
+ */
136
110
  declare function lerp(x: number, y: number, t: number): number;
137
111
  /**
138
112
  * Check if a number is a power-of-n.
@@ -140,9 +114,7 @@ declare function lerp(x: number, y: number, t: number): number;
140
114
  * @param x a number
141
115
  * @param n base
142
116
  * @returns nⁱ = x? | i = +ve integer
143
- * */
144
-
145
-
117
+ */
146
118
  declare function isPow(x: number, n: number): boolean;
147
119
  /**
148
120
  * Find largest power-of-n less than or equal to given number.
@@ -150,9 +122,7 @@ declare function isPow(x: number, n: number): boolean;
150
122
  * @param x a number
151
123
  * @param n base
152
124
  * @returns nⁱ | nⁱ ≤ x and nⁱ > x/n
153
- * */
154
-
155
-
125
+ */
156
126
  declare function prevPow(x: number, n: number): number;
157
127
  /**
158
128
  * Find smallest power-of-n greater than or equal to given number.
@@ -160,9 +130,7 @@ declare function prevPow(x: number, n: number): number;
160
130
  * @param x a number
161
131
  * @param n base
162
132
  * @returns nⁱ | nⁱ ≄ x and nⁱ < n*x
163
- * */
164
-
165
-
133
+ */
166
134
  declare function nextPow(x: number, n: number): number;
167
135
  /**
168
136
  * Find the nth root of a number (ⁿ√).
@@ -170,9 +138,7 @@ declare function nextPow(x: number, n: number): number;
170
138
  * @param x a number
171
139
  * @param n root
172
140
  * @returns ⁿ√x
173
- * */
174
-
175
-
141
+ */
176
142
  declare function root(x: number, n: number): number;
177
143
  /**
178
144
  * Find the logarithm of a number with a given base.
@@ -180,18 +146,14 @@ declare function root(x: number, n: number): number;
180
146
  * @param x a number
181
147
  * @param b logarithm base [e]
182
148
  * @returns log_b (x)
183
- * */
184
-
185
-
149
+ */
186
150
  declare function log(x: number, b?: number): number;
187
151
  /**
188
152
  * List all divisors of a number, except itself.
189
153
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/properDivisors)
190
154
  * @param x a number
191
155
  * @returns proper divisors (factors)
192
- * */
193
-
194
-
156
+ */
195
157
  declare function properDivisors(x: number): number[];
196
158
 
197
159
  /**
@@ -199,18 +161,14 @@ declare function properDivisors(x: number): number[];
199
161
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/aliquotSum)
200
162
  * @param x a number
201
163
  * @returns Ī£dįµ¢ | dįµ¢ is a divisor of x and ≠x
202
- * */
203
-
204
-
164
+ */
205
165
  declare function aliquotSum(x: number): number;
206
166
  /**
207
167
  * Find the least prime number which divides a number.
208
168
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/minPrimeFactor)
209
169
  * @param x a number
210
170
  * @returns least prime factor
211
- * */
212
-
213
-
171
+ */
214
172
  declare function minPrimeFactor(x: number): number;
215
173
 
216
174
  /**
@@ -218,9 +176,7 @@ declare function minPrimeFactor(x: number): number;
218
176
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/maxPrimeFactor)
219
177
  * @param x a number
220
178
  * @returns greatest prime factor
221
- * */
222
-
223
-
179
+ */
224
180
  declare function maxPrimeFactor(x: number): number;
225
181
 
226
182
  /**
@@ -228,36 +184,28 @@ declare function maxPrimeFactor(x: number): number;
228
184
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/primeFactors)
229
185
  * @param x a number
230
186
  * @returns [fā‚€, f₁, ...] | fįµ¢ divides x and is prime
231
- * */
232
-
233
-
187
+ */
234
188
  declare function primeFactors(x: number): number[];
235
189
  /**
236
190
  * Find the prime factors and respective exponents of a number.
237
191
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/primeExponentials)
238
192
  * @param x a number
239
193
  * @returns [[fā‚€, eā‚€], [f₁, e₁], ...] | fįµ¢ is a prime factor of x and eįµ¢ is its exponent
240
- * */
241
-
242
-
194
+ */
243
195
  declare function primeExponentials(x: number): [number, number][];
244
196
  /**
245
197
  * Check if number is prime.
246
198
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/isPrime)
247
199
  * @param x a number
248
200
  * @returns is divisible by 1 and itself only?
249
- * */
250
-
251
-
201
+ */
252
202
  declare function isPrime(x: number): boolean;
253
203
  /**
254
204
  * Find the greatest common divisor of numbers.
255
205
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/gcd)
256
206
  * @param xs a list of numbers
257
207
  * @returns gcd(x₁, xā‚‚, ...)
258
- * */
259
-
260
-
208
+ */
261
209
  declare function gcd(...xs: number[]): number;
262
210
 
263
211
  /**
@@ -265,9 +213,7 @@ declare function gcd(...xs: number[]): number;
265
213
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/lcm)
266
214
  * @param xs a list of numbers
267
215
  * @returns lcm(x₁, xā‚‚, ...)
268
- * */
269
-
270
-
216
+ */
271
217
  declare function lcm(...xs: number[]): number;
272
218
  /**
273
219
  * Find the factorial of a number.
@@ -275,9 +221,7 @@ declare function lcm(...xs: number[]): number;
275
221
  * @param n a number
276
222
  * @param k denominator factorial [0]
277
223
  * @returns P(n, k); k=0: n!, k>0: n!/k!
278
- * */
279
-
280
-
224
+ */
281
225
  declare function factorial(n: number, k?: number): number;
282
226
  /**
283
227
  * Find the number of ways to choose k elements from a set of n elements.
@@ -285,99 +229,77 @@ declare function factorial(n: number, k?: number): number;
285
229
  * @param n elements in source set
286
230
  * @param k elements in choose set
287
231
  * @returns C(n, k)
288
- * */
289
-
290
-
232
+ */
291
233
  declare function binomial(n: number, k: number): number;
292
234
  /**
293
235
  * Find the number of ways to put n objects in m bins (n=sum(kįµ¢)).
294
236
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/multinomial)
295
237
  * @param ks objects per bin (kįµ¢)
296
238
  * @returns n!/(k₁!kā‚‚!...) | n=sum(kįµ¢)
297
- * */
298
-
299
-
239
+ */
300
240
  declare function multinomial(...ks: number[]): number;
301
241
  /**
302
242
  * Convert radians to degrees.
303
243
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/degrees)
304
244
  * @param x radians
305
245
  * @returns 2Ļ€ → 360
306
- * */
307
-
308
-
246
+ */
309
247
  declare function degrees(x: number): number;
310
248
  /**
311
249
  * Convert degrees to radians.
312
250
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/radians)
313
251
  * @param x degrees
314
252
  * @returns 360 → 2Ļ€
315
- * */
316
-
317
-
253
+ */
318
254
  declare function radians(x: number): number;
319
255
  /**
320
256
  * Find the sum of numbers (Ī£).
321
257
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/sum)
322
258
  * @param xs a list of numbers
323
259
  * @returns Ī£xįµ¢
324
- * */
325
-
326
-
260
+ */
327
261
  declare function sum(...xs: number[]): number;
328
262
  /**
329
263
  * Find the product of numbers (āˆ).
330
264
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/product)
331
265
  * @param xs a list of numbers
332
266
  * @returns āˆxįµ¢
333
- * */
334
-
335
-
267
+ */
336
268
  declare function product(...xs: number[]): number;
337
269
  /**
338
270
  * Find the value separating the higher and lower halves of numbers.
339
271
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/median)
340
272
  * @param xs a list of numbers
341
273
  * @returns xā‚˜ | sort(xs) = [..., xā‚˜, ...]
342
- * */
343
-
344
-
274
+ */
345
275
  declare function median(...xs: number[]): number;
346
276
  /**
347
277
  * Find the values that appear most often.
348
278
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/modes)
349
279
  * @param xs a list of numbers
350
280
  * @returns [xā‚˜ā‚, xā‚˜ā‚‚, ...] | count(xā‚˜įµ¢) ≄ count(xįµ¢) āˆ€ xįµ¢ ∈ xs
351
- * */
352
-
353
-
281
+ */
354
282
  declare function modes(...xs: number[]): number[];
355
283
  /**
356
284
  * Find the smallest and largest values.
357
285
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/range)
358
286
  * @param xs a list of numbers
359
287
  * @returns [min(xs), max(xs)]
360
- * */
361
-
362
-
288
+ */
363
289
  declare function range(...xs: number[]): [number, number];
364
290
  /**
365
291
  * Find the mean of squared deviation of numbers from its mean.
366
292
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/variance)
367
293
  * @param xs a list of numbers
368
294
  * @returns σ² = E[(xs - µ)²] | µ = mean(xs)
369
- * */
370
-
371
-
295
+ */
372
296
  declare function variance(...xs: number[]): number;
373
297
  /**
374
298
  * Find the average of numbers.
375
299
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/arithmeticMean)
376
300
  * @param xs a list of numbers
377
301
  * @returns Ī£xįµ¢/n | n = size(xs)
378
- * */
379
-
380
-
302
+ */
381
303
  declare function arithmeticMean(...xs: number[]): number;
382
304
 
383
305
  /**
@@ -385,27 +307,21 @@ declare function arithmeticMean(...xs: number[]): number;
385
307
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/geometricMean)
386
308
  * @param xs a list of numbers
387
309
  * @returns ⁿ√(āˆxįµ¢) | n = size(xs)
388
- * */
389
-
390
-
310
+ */
391
311
  declare function geometricMean(...xs: number[]): number;
392
312
  /**
393
313
  * Find the harmonic mean of numbers.
394
314
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/harmonicMean)
395
315
  * @param xs a list of numbers
396
316
  * @returns n/Ī£(1/xįµ¢) | n = size(xs)
397
- * */
398
-
399
-
317
+ */
400
318
  declare function harmonicMean(...xs: number[]): number;
401
319
  /**
402
320
  * Find the quadriatic mean of numbers.
403
321
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/quadriaticMean)
404
322
  * @param xs a list of numbers
405
323
  * @returns √(Ī£xᵢ²)/n | n = size(xs)
406
- * */
407
-
408
-
324
+ */
409
325
  declare function quadriaticMean(...xs: number[]): number;
410
326
 
411
327
  /**
@@ -413,9 +329,7 @@ declare function quadriaticMean(...xs: number[]): number;
413
329
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/cubicMean)
414
330
  * @param xs a list of numbers
415
331
  * @returns ³√(Ī£xᵢ³)/n | n = size(xs)
416
- * */
417
-
418
-
332
+ */
419
333
  declare function cubicMean(...xs: number[]): number;
420
334
 
421
335
  /**
@@ -423,8 +337,7 @@ declare function cubicMean(...xs: number[]): number;
423
337
  * [šŸ“˜](https://github.com/nodef/extra-math/wiki/magnitude)
424
338
  * @param xs vector ([x, y, z, ...])
425
339
  * @returns √(x² + y² + z²)
426
- * */
427
-
340
+ */
428
341
  declare function magnitude(xs: number[]): number;
429
342
  /**
430
343
  * Calculate the distance between two points.
@@ -432,8 +345,7 @@ declare function magnitude(xs: number[]): number;
432
345
  * @param xs first point ([x, y, z, ...])
433
346
  * @param ys second point ([x, y, z, ...])
434
347
  * @returns √(Ī”x² + Ī”y² + Ī”z²)
435
- * */
436
-
348
+ */
437
349
  declare function distance(xs: number[], ys: number[]): number;
438
350
 
439
351
  export { properDivisors as aliquotParts, aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, maxPrimeFactor as greatestPrimeFactor, harmonicMean, gcd as hcf, isPow, isPrime, lcm, minPrimeFactor as leastPrimeFactor, lerp, log, magnitude, remap as map, maxPrimeFactor, arithmeticMean as mean, median, minPrimeFactor, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, primeExponentials, primeFactors, product, properDivisors, quadriaticMean, radians, range, rem, remap, root, quadriaticMean as rootMeanSquare, round, roundDiv, sum, variance };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-math",
3
- "version": "1.3.50",
3
+ "version": "1.3.52",
4
4
  "description": "A collection of common mathematical functions.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -84,14 +84,14 @@
84
84
  },
85
85
  "homepage": "https://github.com/nodef/extra-math#readme",
86
86
  "devDependencies": {
87
- "@rollup/plugin-commonjs": "^23.0.2",
87
+ "@rollup/plugin-commonjs": "^24.0.0",
88
88
  "@rollup/plugin-node-resolve": "^15.0.1",
89
- "@types/jest": "^29.2.3",
90
- "extra-build": "^2.2.35",
91
- "extra-number": "^2.3.3",
89
+ "@types/jest": "^29.2.5",
90
+ "extra-build": "^2.2.41",
91
+ "extra-number": "^2.3.5",
92
92
  "jest": "^29.3.1",
93
93
  "rollup-plugin-cleanup": "^3.2.1",
94
- "rollup-plugin-dts": "^5.0.0",
95
- "ts-jest": "^29.0.3"
94
+ "rollup-plugin-dts": "^5.1.1",
95
+ "ts-jest": "^29.0.5"
96
96
  }
97
97
  }