@cloudglides/nox 1.1.2 → 1.1.3
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/example/package-lock.json +4 -4
- package/example/package.json +1 -1
- package/package.json +1 -1
- package/src/core.browser.js +1 -1
- package/src/presets.browser.js +15 -0
- package/src/presets.js +0 -7
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"name": "nox-demo",
|
|
9
9
|
"version": "0.0.1",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@cloudglides/nox": "
|
|
11
|
+
"@cloudglides/nox": "^1.1.2",
|
|
12
12
|
"react": "^18.2.0",
|
|
13
13
|
"react-dom": "^18.2.0"
|
|
14
14
|
},
|
|
@@ -300,9 +300,9 @@
|
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
302
|
"node_modules/@cloudglides/nox": {
|
|
303
|
-
"version": "1.1.
|
|
304
|
-
"resolved": "https://registry.npmjs.org/@cloudglides/nox/-/nox-1.1.
|
|
305
|
-
"integrity": "sha512-
|
|
303
|
+
"version": "1.1.2",
|
|
304
|
+
"resolved": "https://registry.npmjs.org/@cloudglides/nox/-/nox-1.1.2.tgz",
|
|
305
|
+
"integrity": "sha512-aUDSCyGlc33yL0tk1uqHTpLL/mHAc/1DyBa6zkMcQ+bU3WOAfWXm9AM+05YMRLyK3hzGg6u3pvRJrWs+nJDZeQ==",
|
|
306
306
|
"license": "ISC"
|
|
307
307
|
},
|
|
308
308
|
"node_modules/@esbuild/aix-ppc64": {
|
package/example/package.json
CHANGED
package/package.json
CHANGED
package/src/core.browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { rng, RNG } from './rng.browser.js';
|
|
2
|
-
export { deterministic } from './presets.js';
|
|
2
|
+
export { deterministic } from './presets.browser.js';
|
|
3
3
|
|
|
4
4
|
export { normal, exponential, uniform, poisson } from './utils/distributions.js';
|
|
5
5
|
export { shuffle, pick, sample } from './utils/sequence.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RNG } from './rng.browser.js';
|
|
2
|
+
import { PCG64 } from './generators/index.js';
|
|
3
|
+
|
|
4
|
+
export const deterministic = (seed) => {
|
|
5
|
+
if (seed === null || seed === undefined) {
|
|
6
|
+
throw new TypeError('Deterministic mode requires an explicit seed');
|
|
7
|
+
}
|
|
8
|
+
if (typeof seed !== 'number' && typeof seed !== 'bigint') {
|
|
9
|
+
throw new TypeError('Seed must be a number or bigint');
|
|
10
|
+
}
|
|
11
|
+
if (typeof seed === 'number' && !Number.isFinite(seed)) {
|
|
12
|
+
throw new Error('Seed must be a finite number');
|
|
13
|
+
}
|
|
14
|
+
return new RNG(PCG64, seed);
|
|
15
|
+
};
|
package/src/presets.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { RNG } from './rng.js';
|
|
2
2
|
import { PCG64 } from './generators/index.js';
|
|
3
3
|
|
|
4
|
-
// Use browser or node entropy
|
|
5
|
-
const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
|
|
6
|
-
const entropyModule = isNode ?
|
|
7
|
-
await import('./utils/entropy.js') :
|
|
8
|
-
await import('./utils/entropy.browser.js');
|
|
9
|
-
const { combined: entropyFunc } = entropyModule;
|
|
10
|
-
|
|
11
4
|
export const deterministic = (seed) => {
|
|
12
5
|
if (seed === null || seed === undefined) {
|
|
13
6
|
throw new TypeError('Deterministic mode requires an explicit seed');
|