smath 1.9.2 → 1.10.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.
- package/dist/index.js +21 -1
- package/package.json +1 -1
- package/types/index.d.ts +13 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SMath = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* @packageDocumentation
|
|
6
|
-
*
|
|
6
|
+
* Small math function library
|
|
7
|
+
*
|
|
8
|
+
* 
|
|
7
9
|
*/
|
|
8
10
|
/**
|
|
9
11
|
* Contains a small math function library including
|
|
@@ -404,6 +406,7 @@ var SMath;
|
|
|
404
406
|
* ```js
|
|
405
407
|
* const sequence = SMath.rseq(-2, 2); // [ 2, 0, 1, -2, -1 ]
|
|
406
408
|
* ```
|
|
409
|
+
* @deprecated Use `SMath.shuffle()` instead
|
|
407
410
|
*/
|
|
408
411
|
function rseq(min, max) {
|
|
409
412
|
min |= 0;
|
|
@@ -416,6 +419,23 @@ var SMath;
|
|
|
416
419
|
return rawData.sort(function (a, b) { return a.index - b.index; }).map(function (a) { return a.value; });
|
|
417
420
|
}
|
|
418
421
|
SMath.rseq = rseq;
|
|
422
|
+
/**
|
|
423
|
+
* Randomize an array of arbitrary elements.
|
|
424
|
+
* @param stack An array of arbitrary elements
|
|
425
|
+
* @returns The `stack` array in a random order
|
|
426
|
+
* @example
|
|
427
|
+
* ```js
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
function shuffle(stack) {
|
|
431
|
+
var rawData = [];
|
|
432
|
+
for (var _i = 0, stack_1 = stack; _i < stack_1.length; _i++) {
|
|
433
|
+
var item = stack_1[_i];
|
|
434
|
+
rawData.push({ index: Math.random(), value: item });
|
|
435
|
+
}
|
|
436
|
+
return rawData.sort(function (a, b) { return a.index - b.index; }).map(function (a) { return a.value; });
|
|
437
|
+
}
|
|
438
|
+
SMath.shuffle = shuffle;
|
|
419
439
|
/**
|
|
420
440
|
* Take the limit of a function. A return value of `NaN` indicates
|
|
421
441
|
* that no limit exists either due to a discontinuity or imaginary value.
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
*
|
|
3
|
+
* Small math function library
|
|
4
|
+
*
|
|
5
|
+
* 
|
|
4
6
|
*/
|
|
5
7
|
/**
|
|
6
8
|
* Contains a small math function library including
|
|
@@ -270,8 +272,18 @@ export declare namespace SMath {
|
|
|
270
272
|
* ```js
|
|
271
273
|
* const sequence = SMath.rseq(-2, 2); // [ 2, 0, 1, -2, -1 ]
|
|
272
274
|
* ```
|
|
275
|
+
* @deprecated Use `SMath.shuffle()` instead
|
|
273
276
|
*/
|
|
274
277
|
function rseq(min: number, max: number): Array<number>;
|
|
278
|
+
/**
|
|
279
|
+
* Randomize an array of arbitrary elements.
|
|
280
|
+
* @param stack An array of arbitrary elements
|
|
281
|
+
* @returns The `stack` array in a random order
|
|
282
|
+
* @example
|
|
283
|
+
* ```js
|
|
284
|
+
* ```
|
|
285
|
+
*/
|
|
286
|
+
function shuffle<T>(stack: Array<T>): Array<T>;
|
|
275
287
|
/**
|
|
276
288
|
* Take the limit of a function. A return value of `NaN` indicates
|
|
277
289
|
* that no limit exists either due to a discontinuity or imaginary value.
|