extra-math 1.3.35 โ†’ 1.3.38

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.
package/README.md CHANGED
@@ -22,7 +22,7 @@ can be obtained. To calculate the number of ways of *ordering items*, use
22
22
  **Real numbers**: *Range* of a number can be controlled with [constrain],
23
23
  [normalize], or [remap]. Use [lerp] for *linear interpolation* (or extrapolation);
24
24
  [root] for calculating the *n-th root* of a number; and [log] to find the
25
- *logarithm* of a number with a given base..
25
+ *logarithm* of a number with a given base.
26
26
 
27
27
  **Geometry**: Perform conversion from [degrees] to [radians] and vice versa.
28
28
  Find the [magnitude] of a vector or [distance] between two points.
package/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Round down a number to specific precision.
3
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/floor)
4
3
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/floor)
5
4
  * @param x a number
6
5
  * @param pre to precision (1)
@@ -10,7 +9,6 @@
10
9
  declare function floor(x: number, pre?: number): number;
11
10
  /**
12
11
  * Round up a number to specific precision.
13
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/ceil)
14
12
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/ceil)
15
13
  * @param x a number
16
14
  * @param pre to precision [1]
@@ -20,7 +18,6 @@ declare function floor(x: number, pre?: number): number;
20
18
  declare function ceil(x: number, pre?: number): number;
21
19
  /**
22
20
  * Round a number to specific precision.
23
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/round)
24
21
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/round)
25
22
  * @param x a number
26
23
  * @param pre to precision [1]
@@ -30,7 +27,6 @@ declare function ceil(x: number, pre?: number): number;
30
27
  declare function round(x: number, pre?: number): number;
31
28
  /**
32
29
  * Perform floor-divison of two numbers.
33
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/floorDiv)
34
30
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/floorDiv)
35
31
  * @param x divisor
36
32
  * @param y dividend
@@ -41,7 +37,6 @@ declare function round(x: number, pre?: number): number;
41
37
  declare function floorDiv(x: number, y: number): number;
42
38
  /**
43
39
  * Perform ceiling-divison of two numbers.
44
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/ceilDiv)
45
40
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/ceilDiv)
46
41
  * @param x divisor
47
42
  * @param y dividend
@@ -52,7 +47,6 @@ declare function floorDiv(x: number, y: number): number;
52
47
  declare function ceilDiv(x: number, y: number): number;
53
48
  /**
54
49
  * Perform rounded-divison of two numbers.
55
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/roundDiv)
56
50
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/roundDiv)
57
51
  * @param x divisor
58
52
  * @param y dividend
@@ -63,7 +57,6 @@ declare function ceilDiv(x: number, y: number): number;
63
57
  declare function roundDiv(x: number, y: number): number;
64
58
  /**
65
59
  * Find the remainder of x/y with sign of x (truncated division).
66
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/rem)
67
60
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/rem)
68
61
  * @param x dividend
69
62
  * @param y divisor
@@ -74,7 +67,6 @@ declare function roundDiv(x: number, y: number): number;
74
67
  declare function rem(x: number, y: number): number;
75
68
  /**
76
69
  * Find the remainder of x/y with sign of y (floored division).
77
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/mod)
78
70
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/mod)
79
71
  * @param x dividend
80
72
  * @param y divisor
@@ -85,7 +77,6 @@ declare function rem(x: number, y: number): number;
85
77
  declare function mod(x: number, y: number): number;
86
78
  /**
87
79
  * Find the remainder of x/y with +ve sign (euclidean division).
88
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/modp)
89
80
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/modp)
90
81
  * @param x dividend
91
82
  * @param y divisor
@@ -96,7 +87,6 @@ declare function mod(x: number, y: number): number;
96
87
  declare function modp(x: number, y: number): number;
97
88
  /**
98
89
  * Constrain a number within a minimum and a maximum value.
99
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/constrain)
100
90
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/constrain)
101
91
  * @param x a number
102
92
  * @param min minimum value
@@ -109,7 +99,6 @@ declare function constrain(x: number, min: number, max: number): number;
109
99
 
110
100
  /**
111
101
  * Normalize a number from its current range into a value between 0 and 1.
112
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/normalize)
113
102
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/normalize)
114
103
  * @param x a number
115
104
  * @param r lower bound of current range
@@ -122,7 +111,6 @@ declare function normalize(x: number, r: number, R: number): number;
122
111
 
123
112
  /**
124
113
  * Re-map a number from one range to another.
125
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/remap)
126
114
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/remap)
127
115
  * @param x a number
128
116
  * @param r lower bound of current range
@@ -137,7 +125,6 @@ declare function remap(x: number, r: number, R: number, t: number, T: number): n
137
125
 
138
126
  /**
139
127
  * Linearly interpolate a number between two numbers.
140
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/lerp)
141
128
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/lerp)
142
129
  * @param x start number
143
130
  * @param y stop number
@@ -149,7 +136,6 @@ declare function remap(x: number, r: number, R: number, t: number, T: number): n
149
136
  declare function lerp(x: number, y: number, t: number): number;
150
137
  /**
151
138
  * Check if a number is a power-of-n.
152
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/isPow)
153
139
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/isPow)
154
140
  * @param x a number
155
141
  * @param n base
@@ -160,7 +146,6 @@ declare function lerp(x: number, y: number, t: number): number;
160
146
  declare function isPow(x: number, n: number): boolean;
161
147
  /**
162
148
  * Get previous power-of-n of a number.
163
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/prevPow)
164
149
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/prevPow)
165
150
  * @param x a number
166
151
  * @param n base
@@ -171,7 +156,6 @@ declare function isPow(x: number, n: number): boolean;
171
156
  declare function prevPow(x: number, n: number): number;
172
157
  /**
173
158
  * Find next power-of-n of a number.
174
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/nextPow)
175
159
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/nextPow)
176
160
  * @param x a number
177
161
  * @param n base
@@ -182,7 +166,6 @@ declare function prevPow(x: number, n: number): number;
182
166
  declare function nextPow(x: number, n: number): number;
183
167
  /**
184
168
  * Find the nth root of a number (โฟโˆš).
185
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/root)
186
169
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/root)
187
170
  * @param x a number
188
171
  * @param n root
@@ -193,7 +176,6 @@ declare function nextPow(x: number, n: number): number;
193
176
  declare function root(x: number, n: number): number;
194
177
  /**
195
178
  * Find the logarithm of a number with a given base.
196
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/log)
197
179
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/log)
198
180
  * @param x a number
199
181
  * @param b logarithm base [e]
@@ -204,7 +186,6 @@ declare function root(x: number, n: number): number;
204
186
  declare function log(x: number, b?: number): number;
205
187
  /**
206
188
  * List all divisors of a number, except itself.
207
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/properDivisors)
208
189
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/properDivisors)
209
190
  * @param x a number
210
191
  * @returns proper divisors (factors)
@@ -214,7 +195,6 @@ declare function log(x: number, b?: number): number;
214
195
  declare function properDivisors(x: number): number[];
215
196
  /**
216
197
  * Sum all proper divisors of a number.
217
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/aliquotSum)
218
198
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/aliquotSum)
219
199
  * @param x a number
220
200
  * @returns ฮฃdแตข | dแตข is a divisor of x and โ‰ x
@@ -224,7 +204,6 @@ declare function properDivisors(x: number): number[];
224
204
  declare function aliquotSum(x: number): number;
225
205
  /**
226
206
  * Check if number is prime.
227
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/isPrime)
228
207
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/isPrime)
229
208
  * @param x a number
230
209
  * @returns is divisible by 1 and itself only?
@@ -234,7 +213,6 @@ declare function aliquotSum(x: number): number;
234
213
  declare function isPrime(x: number): boolean;
235
214
  /**
236
215
  * Find the greatest common divisor of numbers.
237
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/gcd)
238
216
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/gcd)
239
217
  * @param xs a list of numbers
240
218
  * @returns gcd(xโ‚, xโ‚‚, ...)
@@ -245,7 +223,6 @@ declare function gcd(...xs: number[]): number;
245
223
 
246
224
  /**
247
225
  * Find the least common multiple of numbers.
248
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/lcm)
249
226
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/lcm)
250
227
  * @param xs a list of numbers
251
228
  * @returns lcm(xโ‚, xโ‚‚, ...)
@@ -255,7 +232,6 @@ declare function gcd(...xs: number[]): number;
255
232
  declare function lcm(...xs: number[]): number;
256
233
  /**
257
234
  * Find the factorial of a number.
258
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/factorial)
259
235
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/factorial)
260
236
  * @param n a number
261
237
  * @param k denominator factorial [0]
@@ -266,7 +242,6 @@ declare function lcm(...xs: number[]): number;
266
242
  declare function factorial(n: number, k?: number): number;
267
243
  /**
268
244
  * Find the number of ways to choose k elements from a set of n elements.
269
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/binomial)
270
245
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/binomial)
271
246
  * @param n elements in source set
272
247
  * @param k elements in choose set
@@ -277,7 +252,6 @@ declare function factorial(n: number, k?: number): number;
277
252
  declare function binomial(n: number, k: number): number;
278
253
  /**
279
254
  * Find the number of ways to put n objects in m bins (n=sum(kแตข)).
280
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/multinomial)
281
255
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/multinomial)
282
256
  * @param ks objects per bin (kแตข)
283
257
  * @returns n!/(kโ‚!kโ‚‚!...) | n=sum(kแตข)
@@ -287,7 +261,6 @@ declare function binomial(n: number, k: number): number;
287
261
  declare function multinomial(...ks: number[]): number;
288
262
  /**
289
263
  * Convert radians to degrees.
290
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/degrees)
291
264
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/degrees)
292
265
  * @param x radians
293
266
  * @returns 2ฯ€ โ†’ 360
@@ -297,7 +270,6 @@ declare function multinomial(...ks: number[]): number;
297
270
  declare function degrees(x: number): number;
298
271
  /**
299
272
  * Convert degrees to radians.
300
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/radians)
301
273
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/radians)
302
274
  * @param x degrees
303
275
  * @returns 360 โ†’ 2ฯ€
@@ -307,7 +279,6 @@ declare function degrees(x: number): number;
307
279
  declare function radians(x: number): number;
308
280
  /**
309
281
  * Find the sum of numbers (ฮฃ).
310
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/sum)
311
282
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/sum)
312
283
  * @param xs a list of numbers
313
284
  * @returns ฮฃxแตข
@@ -317,7 +288,6 @@ declare function radians(x: number): number;
317
288
  declare function sum(...xs: number[]): number;
318
289
  /**
319
290
  * Find the product of numbers (โˆ).
320
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/product)
321
291
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/product)
322
292
  * @param xs a list of numbers
323
293
  * @returns โˆxแตข
@@ -327,7 +297,6 @@ declare function sum(...xs: number[]): number;
327
297
  declare function product(...xs: number[]): number;
328
298
  /**
329
299
  * Find the value separating the higher and lower halves of numbers.
330
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/median)
331
300
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/median)
332
301
  * @param xs a list of numbers
333
302
  * @returns xโ‚˜ | sort(xs) = [..., xโ‚˜, ...]
@@ -337,7 +306,6 @@ declare function product(...xs: number[]): number;
337
306
  declare function median(...xs: number[]): number;
338
307
  /**
339
308
  * Find the values that appear most often.
340
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/modes)
341
309
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/modes)
342
310
  * @param xs a list of numbers
343
311
  * @returns [xโ‚˜โ‚, xโ‚˜โ‚‚, ...] | count(xโ‚˜แตข) โ‰ฅ count(xแตข) โˆ€ xแตข โˆˆ xs
@@ -347,7 +315,6 @@ declare function median(...xs: number[]): number;
347
315
  declare function modes(...xs: number[]): number[];
348
316
  /**
349
317
  * Find the smallest and largest values.
350
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/range)
351
318
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/range)
352
319
  * @param xs a list of numbers
353
320
  * @returns [min(xs), max(xs)]
@@ -357,7 +324,6 @@ declare function modes(...xs: number[]): number[];
357
324
  declare function range(...xs: number[]): [number, number];
358
325
  /**
359
326
  * Find the mean of squared deviation of numbers from its mean.
360
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/variance)
361
327
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/variance)
362
328
  * @param xs a list of numbers
363
329
  * @returns ฯƒยฒ = E[(xs - ยต)ยฒ] | ยต = mean(xs)
@@ -367,7 +333,6 @@ declare function range(...xs: number[]): [number, number];
367
333
  declare function variance(...xs: number[]): number;
368
334
  /**
369
335
  * Find the average of numbers.
370
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/arithmeticMean)
371
336
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/arithmeticMean)
372
337
  * @param xs a list of numbers
373
338
  * @returns ฮฃxแตข/n | n = size(xs)
@@ -378,7 +343,6 @@ declare function arithmeticMean(...xs: number[]): number;
378
343
 
379
344
  /**
380
345
  * Find the geometric mean of numbers.
381
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/geometricMean)
382
346
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/geometricMean)
383
347
  * @param xs a list of numbers
384
348
  * @returns โฟโˆš(โˆxแตข) | n = size(xs)
@@ -388,7 +352,6 @@ declare function arithmeticMean(...xs: number[]): number;
388
352
  declare function geometricMean(...xs: number[]): number;
389
353
  /**
390
354
  * Find the harmonic mean of numbers.
391
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/harmonicMean)
392
355
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/harmonicMean)
393
356
  * @param xs a list of numbers
394
357
  * @returns n/ฮฃ(1/xแตข) | n = size(xs)
@@ -398,7 +361,6 @@ declare function geometricMean(...xs: number[]): number;
398
361
  declare function harmonicMean(...xs: number[]): number;
399
362
  /**
400
363
  * Find the quadriatic mean of numbers.
401
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/quadriaticMean)
402
364
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/quadriaticMean)
403
365
  * @param xs a list of numbers
404
366
  * @returns โˆš(ฮฃxแตขยฒ)/n | n = size(xs)
@@ -409,7 +371,6 @@ declare function quadriaticMean(...xs: number[]): number;
409
371
 
410
372
  /**
411
373
  * Find the cubic mean of numbers.
412
- * [๐Ÿ“˜](https://github.com/nodef/extra-number/wiki/cubicMean)
413
374
  * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/cubicMean)
414
375
  * @param xs a list of numbers
415
376
  * @returns ยณโˆš(ฮฃxแตขยณ)/n | n = size(xs)
@@ -436,4 +397,4 @@ declare function magnitude(xs: number[]): number;
436
397
 
437
398
  declare function distance(xs: number[], ys: number[]): number;
438
399
 
439
- export { aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, harmonicMean, gcd as hcf, isPow, isPrime, lcm, lerp, log, magnitude, remap as map, median, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, product, properDivisors, quadriaticMean, radians, range, rem, remap, root, round, roundDiv, sum, variance };
400
+ export { aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, harmonicMean, gcd as hcf, isPow, isPrime, lcm, lerp, log, magnitude, remap as map, arithmeticMean as mean, median, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, product, properDivisors, quadriaticMean, radians, range, rem, remap, root, quadriaticMean as rootMeanSquare, round, roundDiv, sum, variance };
package/index.js CHANGED
@@ -266,6 +266,7 @@ exports.lerp = lerp;
266
266
  exports.log = log;
267
267
  exports.magnitude = magnitude;
268
268
  exports.map = remap;
269
+ exports.mean = arithmeticMean;
269
270
  exports.median = median;
270
271
  exports.mod = mod;
271
272
  exports.modes = modes;
@@ -283,6 +284,7 @@ exports.range = range;
283
284
  exports.rem = rem;
284
285
  exports.remap = remap;
285
286
  exports.root = root;
287
+ exports.rootMeanSquare = quadriaticMean;
286
288
  exports.round = round;
287
289
  exports.roundDiv = roundDiv;
288
290
  exports.sum = sum;
package/index.mjs CHANGED
@@ -238,4 +238,4 @@ function distance(xs, ys) {
238
238
  return Math.sqrt(a);
239
239
  }
240
240
 
241
- export { aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, harmonicMean, gcd as hcf, isPow, isPrime, lcm, lerp, log, magnitude, remap as map, median, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, product, properDivisors, quadriaticMean, radians, range, rem, remap, root, round, roundDiv, sum, variance };
241
+ export { aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, harmonicMean, gcd as hcf, isPow, isPrime, lcm, lerp, log, magnitude, remap as map, arithmeticMean as mean, median, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, 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.35",
3
+ "version": "1.3.38",
4
4
  "description": "A collection of common mathematical functions.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -21,7 +21,9 @@
21
21
  "clamp",
22
22
  "hcf",
23
23
  "map",
24
+ "mean",
24
25
  "norm",
26
+ "rootMeanSquare",
25
27
  "aliquotSum",
26
28
  "arithmeticMean",
27
29
  "binomial",