@thi.ng/random 2.4.7 → 3.0.2

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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@thi.ng/random",
3
- "version": "2.4.7",
3
+ "version": "3.0.2",
4
4
  "description": "Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation",
5
+ "type": "module",
5
6
  "module": "./index.js",
6
- "main": "./lib/index.js",
7
- "umd:main": "./lib/index.umd.js",
8
7
  "typings": "./index.d.ts",
8
+ "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/thi-ng/umbrella.git"
@@ -24,30 +24,24 @@
24
24
  "author": "Karsten Schmidt <k+npm@thi.ng>",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module",
28
- "build:release": "yarn clean && yarn build:es6 && node ../../scripts/bundle-module all",
29
- "build:es6": "tsc --declaration",
30
- "build:test": "rimraf build && tsc -p test/tsconfig.json",
31
- "build:check": "tsc --isolatedModules --noEmit",
32
- "test": "mocha test",
33
- "cover": "nyc mocha test && nyc report --reporter=lcov",
34
- "clean": "rimraf *.js *.d.ts *.map .nyc_output build coverage doc lib distributions",
35
- "doc:readme": "ts-node -P ../../tools/tsconfig.json ../../tools/src/readme.ts",
36
- "doc": "typedoc --excludePrivate --out doc --theme ../../tools/doc/typedoc-theme src/index.ts",
27
+ "build": "yarn clean && tsc --declaration",
28
+ "clean": "rimraf *.js *.d.ts *.map doc distributions",
29
+ "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
37
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && node_modules/.bin/api-extractor run --local --verbose",
38
- "pub": "yarn build:release && yarn publish --access public"
31
+ "doc:readme": "yarn doc:stats && ../../scripts/node-esm ../../tools/src/readme.ts",
32
+ "doc:stats": "../../scripts/node-esm ../../tools/src/module-stats.ts",
33
+ "pub": "yarn build && yarn publish --access public",
34
+ "test": "testament test"
39
35
  },
40
36
  "dependencies": {
41
- "@thi.ng/api": "^7.1.9",
42
- "@thi.ng/checks": "^2.9.10",
43
- "@thi.ng/hex": "^1.0.4"
37
+ "@thi.ng/api": "^8.0.2",
38
+ "@thi.ng/checks": "^3.0.2",
39
+ "@thi.ng/errors": "^2.0.2",
40
+ "@thi.ng/hex": "^2.0.2"
41
+ },
42
+ "devDependencies": {
43
+ "@thi.ng/testament": "^0.1.2"
44
44
  },
45
- "files": [
46
- "*.js",
47
- "*.d.ts",
48
- "lib",
49
- "distributions"
50
- ],
51
45
  "keywords": [
52
46
  "binary",
53
47
  "crypto",
@@ -69,12 +63,87 @@
69
63
  "publishConfig": {
70
64
  "access": "public"
71
65
  },
72
- "sideEffects": false,
66
+ "engines": {
67
+ "node": ">=12.7"
68
+ },
69
+ "files": [
70
+ "*.js",
71
+ "*.d.ts",
72
+ "distributions"
73
+ ],
74
+ "exports": {
75
+ ".": {
76
+ "import": "./index.js"
77
+ },
78
+ "./api": {
79
+ "import": "./api.js"
80
+ },
81
+ "./arandom": {
82
+ "import": "./arandom.js"
83
+ },
84
+ "./coin": {
85
+ "import": "./coin.js"
86
+ },
87
+ "./constants": {
88
+ "import": "./constants.js"
89
+ },
90
+ "./crypto": {
91
+ "import": "./crypto.js"
92
+ },
93
+ "./distributions/exponential": {
94
+ "import": "./distributions/exponential.js"
95
+ },
96
+ "./distributions/gaussian": {
97
+ "import": "./distributions/gaussian.js"
98
+ },
99
+ "./distributions/geometric": {
100
+ "import": "./distributions/geometric.js"
101
+ },
102
+ "./distributions/normal": {
103
+ "import": "./distributions/normal.js"
104
+ },
105
+ "./distributions/uniform": {
106
+ "import": "./distributions/uniform.js"
107
+ },
108
+ "./random-bytes": {
109
+ "import": "./random-bytes.js"
110
+ },
111
+ "./random-id": {
112
+ "import": "./random-id.js"
113
+ },
114
+ "./smush32": {
115
+ "import": "./smush32.js"
116
+ },
117
+ "./system": {
118
+ "import": "./system.js"
119
+ },
120
+ "./unique-indices": {
121
+ "import": "./unique-indices.js"
122
+ },
123
+ "./uuid": {
124
+ "import": "./uuid.js"
125
+ },
126
+ "./weighted-random": {
127
+ "import": "./weighted-random.js"
128
+ },
129
+ "./xorshift128": {
130
+ "import": "./xorshift128.js"
131
+ },
132
+ "./xorwow": {
133
+ "import": "./xorwow.js"
134
+ },
135
+ "./xoshiro128": {
136
+ "import": "./xoshiro128.js"
137
+ },
138
+ "./xsadd": {
139
+ "import": "./xsadd.js"
140
+ }
141
+ },
73
142
  "thi.ng": {
74
143
  "year": 2015,
75
144
  "related": [
76
145
  "ksuid"
77
146
  ]
78
147
  },
79
- "gitHead": "3365151f112c39f224541f5ac4cedf3370eb9ba4"
148
+ "gitHead": "3c5f903104da150588946a94bb118ad559ad395d"
80
149
  }
package/random-bytes.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { IRandom } from "./api";
1
+ import type { IRandom } from "./api.js";
2
2
  /**
3
3
  * Fills given byte array with random values sourced from given {@link IRandom}
4
4
  * instance.
package/random-bytes.js CHANGED
@@ -1,5 +1,5 @@
1
- import { hasCrypto } from "@thi.ng/checks";
2
- import { SYSTEM } from "./system";
1
+ import { hasCrypto } from "@thi.ng/checks/has-crypto";
2
+ import { SYSTEM } from "./system.js";
3
3
  /**
4
4
  * Fills given byte array with random values sourced from given {@link IRandom}
5
5
  * instance.
package/random-id.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { IRandom } from "./api";
1
+ import type { IRandom } from "./api.js";
2
2
  /**
3
3
  * Generates and returns a random string of `len` characters (default 4), plus
4
4
  * optional given `prefix` and using only provided `syms` characters (default
package/random-id.js CHANGED
@@ -1,4 +1,4 @@
1
- import { SYSTEM } from "./system";
1
+ import { SYSTEM } from "./system.js";
2
2
  /**
3
3
  * Generates and returns a random string of `len` characters (default 4), plus
4
4
  * optional given `prefix` and using only provided `syms` characters (default
package/smush32.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IBuffered, ICopy } from "@thi.ng/api";
2
- import type { ISeedable } from "./api";
3
- import { ARandom } from "./arandom";
2
+ import type { ISeedable } from "./api.js";
3
+ import { ARandom } from "./arandom.js";
4
4
  /**
5
5
  * @remarks
6
6
  * References:
package/smush32.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ARandom } from "./arandom";
2
- import { DEFAULT_SEED_32 } from "./constants";
1
+ import { ARandom } from "./arandom.js";
2
+ import { DEFAULT_SEED_32 } from "./constants.js";
3
3
  /**
4
4
  * @remarks
5
5
  * References:
package/system.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ARandom } from "./arandom";
1
+ import { ARandom } from "./arandom.js";
2
2
  /**
3
3
  * A `Math.random()` based {@link IRandom} implementation. Also @see
4
4
  * {@link SYSTEM}.
package/system.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ARandom } from "./arandom";
1
+ import { ARandom } from "./arandom.js";
2
2
  const random = Math.random;
3
3
  /**
4
4
  * A `Math.random()` based {@link IRandom} implementation. Also @see
@@ -1,5 +1,5 @@
1
- import { Fn0 } from "@thi.ng/api";
2
- import type { IRandom } from "./api";
1
+ import type { Fn0 } from "@thi.ng/api";
2
+ import type { IRandom } from "./api.js";
3
3
  /**
4
4
  * Attempts to draw `k` unique values from given zero-arg function `fn`
5
5
  * (presumably a PRNG of sorts) and adds them to `existing` array of unique
package/unique-indices.js CHANGED
@@ -1,5 +1,5 @@
1
- import { assert } from "@thi.ng/api";
2
- import { SYSTEM } from "./system";
1
+ import { assert } from "@thi.ng/errors/assert";
2
+ import { SYSTEM } from "./system.js";
3
3
  /**
4
4
  * Attempts to draw `k` unique values from given zero-arg function `fn`
5
5
  * (presumably a PRNG of sorts) and adds them to `existing` array of unique
package/uuid.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { IRandom } from "./api";
1
+ import type { IRandom } from "./api.js";
2
2
  /**
3
3
  * Depending on if `rnd` is given, uses {@link randomBytesFrom} or
4
4
  * {@link randomBytes} to fill given (optional) byte array with a new UUIDv4.
package/uuid.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { uuid as $uuid } from "@thi.ng/hex";
2
- import { randomBytes, randomBytesFrom } from "./random-bytes";
2
+ import { randomBytes, randomBytesFrom } from "./random-bytes.js";
3
3
  /**
4
4
  * Depending on if `rnd` is given, uses {@link randomBytesFrom} or
5
5
  * {@link randomBytes} to fill given (optional) byte array with a new UUIDv4.
@@ -1,4 +1,4 @@
1
- import type { IRandom } from "./api";
1
+ import type { IRandom } from "./api.js";
2
2
  /**
3
3
  * Returns a no-arg function which produces a random choice of given weighted
4
4
  * `choices` and using given {@link IRandom} instance (default {@link SYSTEM}.
@@ -1,5 +1,5 @@
1
- import { assert } from "@thi.ng/api";
2
- import { SYSTEM } from "./system";
1
+ import { assert } from "@thi.ng/errors/assert";
2
+ import { SYSTEM } from "./system.js";
3
3
  /**
4
4
  * Returns a no-arg function which produces a random choice of given weighted
5
5
  * `choices` and using given {@link IRandom} instance (default {@link SYSTEM}.
package/xorshift128.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IBuffered, ICopy } from "@thi.ng/api";
2
- import type { ISeedable } from "./api";
3
- import { ARandom } from "./arandom";
2
+ import type { ISeedable } from "./api.js";
3
+ import { ARandom } from "./arandom.js";
4
4
  /**
5
5
  * @remarks
6
6
  * Reference: https://en.wikipedia.org/wiki/Xorshift
package/xorshift128.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ARandom } from "./arandom";
2
- import { DEFAULT_SEED_128 } from "./constants";
1
+ import { ARandom } from "./arandom.js";
2
+ import { DEFAULT_SEED_128 } from "./constants.js";
3
3
  /**
4
4
  * @remarks
5
5
  * Reference: https://en.wikipedia.org/wiki/Xorshift
package/xorwow.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IBuffered, ICopy } from "@thi.ng/api";
2
- import type { ISeedable } from "./api";
3
- import { ARandom } from "./arandom";
2
+ import type { ISeedable } from "./api.js";
3
+ import { ARandom } from "./arandom.js";
4
4
  /**
5
5
  * @remarks
6
6
  * Reference: https://en.wikipedia.org/wiki/Xorshift#xorwow
package/xorwow.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ARandom } from "./arandom";
2
- import { DEFAULT_SEED_160 } from "./constants";
1
+ import { ARandom } from "./arandom.js";
2
+ import { DEFAULT_SEED_160 } from "./constants.js";
3
3
  /**
4
4
  * @remarks
5
5
  * Reference: https://en.wikipedia.org/wiki/Xorshift#xorwow
package/xoshiro128.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IBuffered, ICopy } from "@thi.ng/api";
2
- import type { ISeedable } from "./api";
3
- import { ARandom } from "./arandom";
2
+ import type { ISeedable } from "./api.js";
3
+ import { ARandom } from "./arandom.js";
4
4
  /**
5
5
  * @remarks
6
6
  * References:
package/xoshiro128.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ARandom } from "./arandom";
2
- import { DEFAULT_SEED_128 } from "./constants";
1
+ import { ARandom } from "./arandom.js";
2
+ import { DEFAULT_SEED_128 } from "./constants.js";
3
3
  /**
4
4
  * @remarks
5
5
  * References:
package/xsadd.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { IBuffered, ICopy } from "@thi.ng/api";
2
- import type { ISeedable } from "./api";
3
- import { ARandom } from "./arandom";
2
+ import type { ISeedable } from "./api.js";
3
+ import { ARandom } from "./arandom.js";
4
4
  /**
5
5
  * @remarks
6
6
  * Reference: https://github.com/MersenneTwister-Lab/XSadd/blob/develop/xsadd.h
package/xsadd.js CHANGED
@@ -1,5 +1,5 @@
1
- import { ARandom } from "./arandom";
2
- import { DEFAULT_SEED_32 } from "./constants";
1
+ import { ARandom } from "./arandom.js";
2
+ import { DEFAULT_SEED_32 } from "./constants.js";
3
3
  /**
4
4
  * @remarks
5
5
  * Reference: https://github.com/MersenneTwister-Lab/XSadd/blob/develop/xsadd.h