@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/CHANGELOG.md +83 -148
- package/README.md +22 -11
- package/arandom.d.ts +1 -1
- package/coin.d.ts +1 -1
- package/coin.js +1 -1
- package/crypto.d.ts +1 -1
- package/crypto.js +2 -2
- package/distributions/exponential.d.ts +1 -1
- package/distributions/exponential.js +1 -1
- package/distributions/gaussian.d.ts +1 -1
- package/distributions/gaussian.js +1 -1
- package/distributions/geometric.d.ts +1 -1
- package/distributions/geometric.js +1 -1
- package/distributions/normal.d.ts +1 -1
- package/distributions/normal.js +1 -1
- package/distributions/uniform.d.ts +1 -1
- package/distributions/uniform.js +1 -1
- package/index.d.ts +20 -20
- package/index.js +20 -20
- package/package.json +94 -25
- package/random-bytes.d.ts +1 -1
- package/random-bytes.js +2 -2
- package/random-id.d.ts +1 -1
- package/random-id.js +1 -1
- package/smush32.d.ts +2 -2
- package/smush32.js +2 -2
- package/system.d.ts +1 -1
- package/system.js +1 -1
- package/unique-indices.d.ts +2 -2
- package/unique-indices.js +2 -2
- package/uuid.d.ts +1 -1
- package/uuid.js +1 -1
- package/weighted-random.d.ts +1 -1
- package/weighted-random.js +2 -2
- package/xorshift128.d.ts +2 -2
- package/xorshift128.js +2 -2
- package/xorwow.d.ts +2 -2
- package/xorwow.js +2 -2
- package/xoshiro128.d.ts +2 -2
- package/xoshiro128.js +2 -2
- package/xsadd.d.ts +2 -2
- package/xsadd.js +2 -2
- package/lib/index.js +0 -365
- package/lib/index.js.map +0 -1
- package/lib/index.umd.js +0 -1
- package/lib/index.umd.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/random",
|
|
3
|
-
"version": "
|
|
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 &&
|
|
28
|
-
"
|
|
29
|
-
"
|
|
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
|
-
"
|
|
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": "^
|
|
42
|
-
"@thi.ng/checks": "^
|
|
43
|
-
"@thi.ng/
|
|
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
|
-
"
|
|
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": "
|
|
148
|
+
"gitHead": "3c5f903104da150588946a94bb118ad559ad395d"
|
|
80
149
|
}
|
package/random-bytes.d.ts
CHANGED
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
package/random-id.js
CHANGED
package/smush32.d.ts
CHANGED
package/smush32.js
CHANGED
package/system.d.ts
CHANGED
package/system.js
CHANGED
package/unique-indices.d.ts
CHANGED
|
@@ -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/
|
|
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
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.
|
package/weighted-random.d.ts
CHANGED
package/weighted-random.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { assert } from "@thi.ng/
|
|
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
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
package/xoshiro128.d.ts
CHANGED
package/xoshiro128.js
CHANGED
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
|