@esportsplus/random 0.0.6 → 0.0.8

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/build/coinflip.js CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
  export default () => {
3
3
  return rng() < 0.5;
4
4
  };
package/build/item.js CHANGED
@@ -1,4 +1,4 @@
1
- import rng from "./rng";
1
+ import { rng } from '@esportsplus/crypto';
2
2
  const BASIS_POINTS = 10000;
3
3
  export default (items, weights) => {
4
4
  if (weights === undefined) {
package/build/range.js CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
  export default (min, max, integer = false) => {
3
3
  if (!integer) {
4
4
  return rng() * (max - min) + min;
package/build/roll.js CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
  export default (percentage) => {
3
3
  return rng() <= percentage;
4
4
  };
package/build/shuffle.js CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
  export default (values) => {
3
3
  let n = values.length, random, value;
4
4
  while (--n > 0) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "ICJR",
3
3
  "description": "Random",
4
4
  "devDependencies": {
5
- "@esportsplus/rspack": "^0.0.10"
5
+ "@esportsplus/rspack": "^0.0.15"
6
6
  },
7
7
  "main": "build/index.js",
8
8
  "name": "@esportsplus/random",
@@ -14,5 +14,8 @@
14
14
  "prepublishOnly": "npm run build"
15
15
  },
16
16
  "types": "build/index.d.ts",
17
- "version": "0.0.6"
17
+ "version": "0.0.8",
18
+ "dependencies": {
19
+ "@esportsplus/crypto": "^0.0.4"
20
+ }
18
21
  }
package/src/coinflip.ts CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
 
3
3
 
4
4
  export default () => {
package/src/item.ts CHANGED
@@ -1,4 +1,4 @@
1
- import rng from "./rng";
1
+ import { rng } from '@esportsplus/crypto';
2
2
 
3
3
 
4
4
  const BASIS_POINTS = 10000;
package/src/range.ts CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
 
3
3
 
4
4
  export default (min: number, max: number, integer = false) => {
package/src/roll.ts CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
 
3
3
 
4
4
  export default (percentage: number) => {
package/src/shuffle.ts CHANGED
@@ -1,4 +1,4 @@
1
- import rng from './rng';
1
+ import { rng } from '@esportsplus/crypto';
2
2
 
3
3
 
4
4
  // Fisher-Yates shuffle
package/build/float.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import rng from './rng';
2
- export default rng;
package/build/float.js DELETED
@@ -1,2 +0,0 @@
1
- import rng from './rng';
2
- export default rng;
package/build/floats.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare const _default: (n: number) => number[];
2
- export default _default;
package/build/floats.js DELETED
@@ -1,9 +0,0 @@
1
- import rng from './rng';
2
- import shuffle from './shuffle';
3
- export default (n) => {
4
- let values = [];
5
- for (let i = 0; i < n; i++) {
6
- values.push(rng());
7
- }
8
- return shuffle(values);
9
- };
@@ -1,2 +0,0 @@
1
- declare const _default: () => number;
2
- export default _default;
package/build/integer.js DELETED
@@ -1,4 +0,0 @@
1
- import rng from './rng';
2
- export default () => {
3
- return Math.floor(rng());
4
- };
@@ -1,2 +0,0 @@
1
- declare const _default: (n: number) => any[];
2
- export default _default;
package/build/integers.js DELETED
@@ -1,9 +0,0 @@
1
- import rng from './rng';
2
- import shuffle from './shuffle';
3
- export default (n) => {
4
- let values = [];
5
- for (let i = 0; i < n; i++) {
6
- values.push(Math.floor(rng()));
7
- }
8
- return shuffle(values);
9
- };
package/build/rng.d.ts DELETED
@@ -1,2 +0,0 @@
1
- declare let rng: () => number;
2
- export default rng;
package/build/rng.js DELETED
@@ -1,11 +0,0 @@
1
- let max = Math.pow(2, 32), rng;
2
- if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
3
- rng = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / max;
4
- }
5
- else if (typeof process !== 'undefined' && process.versions != null && process.versions.node != null) {
6
- rng = () => require('crypto').randomBytes(4).readUInt32BE(0) / max;
7
- }
8
- else {
9
- throw new Error('Random: no suitable random number generator found');
10
- }
11
- export default rng;
package/src/rng.ts DELETED
@@ -1,16 +0,0 @@
1
- let max = Math.pow(2, 32),
2
- rng: () => number;
3
-
4
-
5
- if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {
6
- rng = () => window.crypto.getRandomValues(new Uint32Array(1))[0] / max;
7
- }
8
- else if (typeof process !== 'undefined' && process.versions != null && process.versions.node != null) {
9
- rng = () => require('crypto').randomBytes(4).readUInt32BE(0) / max;
10
- }
11
- else {
12
- throw new Error('Random: no suitable random number generator found');
13
- }
14
-
15
-
16
- export default rng;