smath 1.8.6 → 1.9.1

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/bin.js CHANGED
@@ -40,6 +40,7 @@ if (func.includes('help')) {
40
40
  console.log(' rint <min> <max> : Generate a uniformly-distributed random integer, range inclusive');
41
41
  console.log(' rnorm [mean] [stdev] : Generate a normally-distributed random float');
42
42
  console.log(' rdist <n> [mean] [stdev] : Generate `n` normally-distributed random floats');
43
+ console.log(' rseq <min> <max> : Randomize a sequence of integers from `min` to `max`');
43
44
  process.exit(1);
44
45
  }
45
46
  switch (func) {
@@ -131,6 +132,10 @@ switch (func) {
131
132
  console.log(_1.SMath.rdist(nums[0], nums[1], nums[2]));
132
133
  break;
133
134
  }
135
+ case ('rseq'): {
136
+ console.log(_1.SMath.rseq(nums[0], nums[1]));
137
+ break;
138
+ }
134
139
  case (''): {
135
140
  console.error('Missing argument. Use with "help" for a list of commands.');
136
141
  process.exit(1);
package/dist/index.js CHANGED
@@ -395,6 +395,27 @@ var SMath;
395
395
  return distribution;
396
396
  }
397
397
  SMath.rdist = rdist;
398
+ /**
399
+ * Randomize a sequence of integers from `min` to `max`.
400
+ * @param min The minimum integer in the randomized sequence
401
+ * @param max The maximum integer in the randomized sequence
402
+ * @returns A randomized sequence of integers from `min` to `max`
403
+ * @example
404
+ * ```js
405
+ * const sequence = SMath.rseq(-2, 2); // [ 2, 0, 1, -2, -1 ]
406
+ * ```
407
+ */
408
+ function rseq(min, max) {
409
+ min |= 0;
410
+ max |= 0;
411
+ max++;
412
+ var rawData = [];
413
+ for (var i = min; i < max; i++) {
414
+ rawData.push({ index: runif(-1, 1), value: i });
415
+ }
416
+ return rawData.sort(function (a, b) { return a.index - b.index; }).map(function (a) { return a.value; });
417
+ }
418
+ SMath.rseq = rseq;
398
419
  /**
399
420
  * Take the limit of a function. A return value of `NaN` indicates
400
421
  * that no limit exists either due to a discontinuity or imaginary value.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smath",
3
- "version": "1.8.6",
3
+ "version": "1.9.1",
4
4
  "description": "Small math function library",
5
5
  "homepage": "https://npm.nicfv.com/",
6
6
  "bin": "dist/bin.js",
@@ -55,7 +55,7 @@
55
55
  "repository": "github:nicfv/npm",
56
56
  "license": "MIT",
57
57
  "devDependencies": {
58
- "@types/node": "20.12.7",
59
- "t6": "1.1.4"
58
+ "@types/node": "22.10.1",
59
+ "t6": "1.1.5"
60
60
  }
61
61
  }
package/types/index.d.ts CHANGED
@@ -261,6 +261,17 @@ export declare namespace SMath {
261
261
  * ```
262
262
  */
263
263
  function rdist(count: number, mean?: number, stdev?: number): Array<number>;
264
+ /**
265
+ * Randomize a sequence of integers from `min` to `max`.
266
+ * @param min The minimum integer in the randomized sequence
267
+ * @param max The maximum integer in the randomized sequence
268
+ * @returns A randomized sequence of integers from `min` to `max`
269
+ * @example
270
+ * ```js
271
+ * const sequence = SMath.rseq(-2, 2); // [ 2, 0, 1, -2, -1 ]
272
+ * ```
273
+ */
274
+ function rseq(min: number, max: number): Array<number>;
264
275
  /**
265
276
  * Take the limit of a function. A return value of `NaN` indicates
266
277
  * that no limit exists either due to a discontinuity or imaginary value.