toosoon-prng 1.1.0 → 1.2.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/lib/prng.js CHANGED
@@ -1,77 +1,158 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRNGMethod = void 0;
4
- var utils_1 = require("./utils");
5
- var PRNGMethod;
6
- (function (PRNGMethod) {
7
- PRNGMethod["jsf32"] = "jsf32";
8
- PRNGMethod["mulberry32"] = "mulberry32";
9
- PRNGMethod["sfc32"] = "sfc32";
10
- PRNGMethod["xoshiro128ss"] = "xoshiro128**";
11
- })(PRNGMethod || (exports.PRNGMethod = PRNGMethod = {}));
1
+ import { cyrb128, jsf32, mulberry32, sfc32, splitmix32, xoshiro128ss } from './utils';
2
+ export var Algorithm;
3
+ (function (Algorithm) {
4
+ Algorithm["jsf32"] = "jsf32";
5
+ Algorithm["mulberry32"] = "mulberry32";
6
+ Algorithm["sfc32"] = "sfc32";
7
+ Algorithm["splitmix32"] = "splitmix32";
8
+ Algorithm["xoshiro128ss"] = "xoshiro128**";
9
+ })(Algorithm || (Algorithm = {}));
10
+ /**
11
+ * PRNG class
12
+ *
13
+ * @class PRNG
14
+ */
12
15
  var PRNG = /** @class */ (function () {
13
- function PRNG(seed) {
14
- if (seed === void 0) { seed = ''; }
16
+ function PRNG() {
15
17
  this.seed = '';
16
- this.method = PRNGMethod.sfc32;
18
+ this.algorithm = Algorithm.splitmix32;
17
19
  this.controllers = [];
18
- this.setSeed(seed);
19
20
  }
21
+ /**
22
+ * Add a controller to this PRNG
23
+ *
24
+ * @param {PRNGController} controller
25
+ */
20
26
  PRNG.prototype.addController = function (controller) {
21
27
  this.controllers.push(controller);
22
28
  };
29
+ /**
30
+ * Remove a controller from this PRNG
31
+ *
32
+ * @param {PRNGController} controller
33
+ */
23
34
  PRNG.prototype.removeController = function (controller) {
24
35
  var index = this.controllers.indexOf(controller);
25
36
  this.controllers.splice(index, 1);
26
37
  };
38
+ /**
39
+ * Set this PRNG seed
40
+ *
41
+ * @param {string} seed
42
+ */
27
43
  PRNG.prototype.setSeed = function (seed) {
28
44
  if (this.seed === seed)
29
45
  return;
30
46
  this.seed = seed;
31
47
  this.controllers.forEach(function (controller) { return controller.getValue(); });
32
48
  };
33
- PRNG.prototype.setMethod = function (method) {
34
- this.method = method;
49
+ /**
50
+ * Set this PRNG algorithm for generating pseudo-random values
51
+ *
52
+ * @param {Algorithm} algorithm Algorithm name
53
+ */
54
+ PRNG.prototype.setAlgorithm = function (algorithm) {
55
+ this.algorithm = algorithm;
56
+ this.controllers.forEach(function (controller) { return controller.getValue(); });
35
57
  };
58
+ /**
59
+ * Generate a pseudo-random number in the interval [0, 1]
60
+ * PRNG equivalent of `Math.random()`
61
+ *
62
+ * @param {string} seed
63
+ * @returns {number}
64
+ */
36
65
  PRNG.prototype.random = function (seed) {
37
- var hashes = (0, utils_1.cyrb128)(this.seed + seed);
38
- switch (this.method) {
39
- case PRNGMethod.jsf32:
40
- return (0, utils_1.jsf32)(hashes[0], hashes[1], hashes[2], hashes[3]);
41
- case PRNGMethod.mulberry32:
42
- return (0, utils_1.mulberry32)(hashes[0]);
43
- case PRNGMethod.sfc32:
44
- return (0, utils_1.sfc32)(hashes[0], hashes[1], hashes[2], hashes[3]);
45
- case PRNGMethod.xoshiro128ss:
46
- return (0, utils_1.xoshiro128ss)(hashes[0], hashes[1], hashes[2], hashes[3]);
66
+ var hashes = cyrb128(this.seed + seed);
67
+ switch (this.algorithm) {
68
+ case Algorithm.splitmix32:
69
+ return splitmix32(hashes[0]);
70
+ case Algorithm.jsf32:
71
+ return jsf32(hashes[0], hashes[1], hashes[2], hashes[3]);
72
+ case Algorithm.mulberry32:
73
+ return mulberry32(hashes[0]);
74
+ case Algorithm.sfc32:
75
+ return sfc32(hashes[0], hashes[1], hashes[2], hashes[3]);
76
+ case Algorithm.xoshiro128ss:
77
+ return xoshiro128ss(hashes[0], hashes[1], hashes[2], hashes[3]);
47
78
  }
48
79
  };
80
+ /**
81
+ * Generate a pseudo-random boolean (true or false)
82
+ *
83
+ * @param {string} seed
84
+ * @param {number} [probability=0.5] Probability to get `true`
85
+ * @returns {boolean} Either `true` or `false`
86
+ */
49
87
  PRNG.prototype.randomBoolean = function (seed, probability) {
50
88
  if (probability === void 0) { probability = 0.5; }
51
89
  return this.random(seed) < probability;
52
90
  };
91
+ /**
92
+ * Generate a pseudo-random sign (1 or -1)
93
+ *
94
+ * @param {string} seed
95
+ * @param {number} [probability=0.5] Probability to get 1
96
+ * @returns {number} Either 1 or -1
97
+ */
53
98
  PRNG.prototype.randomSign = function (seed, probability) {
54
99
  if (probability === void 0) { probability = 0.5; }
55
100
  return this.randomBoolean(seed, probability) ? 1 : -1;
56
101
  };
102
+ /**
103
+ * Generate a pseudo-random floating-point number within a specified range
104
+ *
105
+ * @param {string} seed
106
+ * @param {number} [min=0] Minimum boundary
107
+ * @param {number} [max=1] Maximum boundary
108
+ * @param {number} [precision=2] Number of digits after the decimal point
109
+ * @returns {number} Generated float
110
+ */
57
111
  PRNG.prototype.randomFloat = function (seed, min, max, precision) {
58
112
  if (min === void 0) { min = 0; }
59
113
  if (max === void 0) { max = 1; }
60
114
  if (precision === void 0) { precision = 2; }
61
115
  return parseFloat(Math.min(min + this.random(seed) * (max - min), max).toFixed(precision));
62
116
  };
117
+ /**
118
+ * Generate a pseudo-random integer number within a specified range
119
+ *
120
+ * @param {string} seed
121
+ * @param {number} min Minimum boundary
122
+ * @param {number} max Maximum boundary
123
+ * @returns {number} Generated integer
124
+ */
63
125
  PRNG.prototype.randomInt = function (seed, min, max) {
64
126
  return Math.floor(this.random(seed) * (max - min + 1) + min);
65
127
  };
128
+ /**
129
+ * Generate a pseudo-random hexadecimal color
130
+ *
131
+ * @param {string} seed
132
+ * @returns {string} Generated hexadecimal color
133
+ */
66
134
  PRNG.prototype.randomHexColor = function (seed) {
67
135
  return '#' + ('00000' + ((this.random(seed) * (1 << 24)) | 0).toString(16)).slice(-6);
68
136
  };
137
+ /**
138
+ * Pick a pseudo-random item from a given array
139
+ *
140
+ * @param {string} seed
141
+ * @param {T[]} array Array to pick the item from
142
+ * @returns {T|undefined} Random item picked
143
+ */
69
144
  PRNG.prototype.randomItem = function (seed, array) {
70
- if (array === void 0) { array = []; }
71
145
  if (array.length === 0)
72
146
  return undefined;
73
147
  return array[this.randomInt(seed, 0, array.length - 1)];
74
148
  };
149
+ /**
150
+ * Pick a pseudo-random property value from a given object
151
+ *
152
+ * @param {string} seed
153
+ * @param {object} object Object to pick the property from
154
+ * @returns {T|undefined} Random item picked
155
+ */
75
156
  PRNG.prototype.randomObjectProperty = function (seed, object) {
76
157
  var keys = Object.keys(object);
77
158
  var key = this.randomItem(seed, keys);
@@ -79,8 +160,14 @@ var PRNG = /** @class */ (function () {
79
160
  return object[key];
80
161
  }
81
162
  };
163
+ /**
164
+ * Select a pseudo-random index from an array of weighted items
165
+ *
166
+ * @param {string} seed
167
+ * @param {number[]} weights Array of weights
168
+ * @returns {number} Random index based on weights
169
+ */
82
170
  PRNG.prototype.randomIndex = function (seed, weights) {
83
- if (weights === void 0) { weights = []; }
84
171
  if (weights.length === 0)
85
172
  return -1;
86
173
  var totalWeight = 0;
@@ -101,4 +188,4 @@ var PRNG = /** @class */ (function () {
101
188
  return PRNG;
102
189
  }());
103
190
  var prng = new PRNG();
104
- exports.default = prng;
191
+ export default prng;
@@ -1 +1 @@
1
- {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.es2023.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/typescript/lib/lib.es2023.array.d.ts","../node_modules/typescript/lib/lib.es2023.collection.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/toosoon-gui/lib/wrapper.d.ts","../node_modules/toosoon-gui/lib/types.d.ts","../node_modules/toosoon-gui/lib/controllers/controller.d.ts","../node_modules/toosoon-gui/lib/controllers/angle-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/color-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/coords-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/file-controller.d.ts","../node_modules/toosoon-gui/lib/gui.d.ts","../node_modules/toosoon-gui/lib/controllers/boolean-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/function-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/number-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/option-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/string-controller.d.ts","../node_modules/toosoon-gui/lib/index.d.ts","../src/utils.ts","../src/prng.ts","../src/controllers.ts","../src/index.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","impliedFormat":1},{"version":"9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","impliedFormat":1},{"version":"5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","impliedFormat":1},{"version":"1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","impliedFormat":1},{"version":"bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c","impliedFormat":1},{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true,"impliedFormat":1},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true,"impliedFormat":1},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true,"impliedFormat":1},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true,"impliedFormat":1},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true,"impliedFormat":1},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true,"impliedFormat":1},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true,"impliedFormat":1},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true,"impliedFormat":1},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true,"impliedFormat":1},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true,"impliedFormat":1},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true,"impliedFormat":1},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true,"impliedFormat":1},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true,"impliedFormat":1},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true,"impliedFormat":1},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true,"impliedFormat":1},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true,"impliedFormat":1},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true,"impliedFormat":1},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true,"impliedFormat":1},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true,"impliedFormat":1},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true,"impliedFormat":1},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true,"impliedFormat":1},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true,"impliedFormat":1},{"version":"4350e5922fecd4bedda2964d69c213a1436349d0b8d260dd902795f5b94dc74b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true,"impliedFormat":1},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"15699b76985193f968dcb28d707dae8e363edb7b3c10d9a1b9a9da18eab101c5","impliedFormat":1},{"version":"a4dc9eec880d0e91c66119b8e0f0f33e0948016a48b9ffb2aabc5dca12130bfa","impliedFormat":1},{"version":"c15c72246f26117c4e232ede5d394b80c6c983fb73a3d92ede4da3cf5dd44564","impliedFormat":1},{"version":"6339a44514a06c5e8f726cf27fc7fb2bf0e2ce5fe0de5545e4d412ba54c209f9","impliedFormat":1},{"version":"52800b74e97d62cd27f91a19ace28ca7ed32084fc5de80b015c8b62aabb4de99","impliedFormat":1},{"version":"2eba4de3285ccf1518aa5d87c683e4c4da38a837f69e112710fb107c58e86b9f","impliedFormat":1},{"version":"7b1267119c9c7c148ee973f8affd943c49f7ec2f5573f83cee25139492b533cd","impliedFormat":1},{"version":"1361b028bda65af72410feed749981eb80ced6439adf892ead6383fd779aa36e","impliedFormat":1},{"version":"027d78906c03890d8473731baca3acad76095aa2e68af1c6fcd32ded61d9a430","impliedFormat":1},{"version":"5eb3db8ef1b8f4eb5b16facea0a1cc3d9c22d6513de77a29c6630233c7ccf888","impliedFormat":1},{"version":"448bf4331abf7995b2ab5c4a449800e35fc3dbcfb522ed752d84564fd7d17374","impliedFormat":1},{"version":"3147a65dfdc1827b3a1b3899c5b316e8cc10eeb66f5c26c758bb24b2c962983a","impliedFormat":1},{"version":"845075e15760edf65e31220cbfc67b0bd436be0cd169181aa524dcf8987ff09e","impliedFormat":1},{"version":"74427eecc65d24613d8483cb6191d32cb91aa79c2b13084ed2062457e3aa0376","impliedFormat":1},{"version":"50b0ac11d8ac3c1ffc3d96b2047de1f23a71a34ef45278dab9db9663ac34ba43","signature":"a33086c14ef04ee690a02c14ed96e979a244182c9c16c01f8e341d56c4bb25e1","impliedFormat":1},{"version":"88053433ff745a552451faf423790b2a4db3de3fbfbc205c1ab52e0d4961a047","signature":"c6ba19df4fc61bdf6e16e5a2a038eb8f2ec5f96dfe09c6d7ed5482050a86dd10","impliedFormat":1},{"version":"b48c362614657ce2812efed65f794e528ae6166ea47130e8ef39a93d971855b7","signature":"c9684c667c5c5a72e3cd40181c0fc9068b3b81ea9026096ca19146813508bf37","impliedFormat":1},{"version":"981120ddc2c9d13e10bc9dc1abff16319a52d109b7ddb41698997d276d0763ae","signature":"d92f8758d3beb4df4bc2a1322aaa133aa2c8781c8916db3367aa14821e65d50d","impliedFormat":1}],"root":[[79,82]],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":true,"experimentalDecorators":true,"module":199,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","skipLibCheck":true,"strict":true,"target":1},"fileIdsList":[[67,72],[66,72],[66,67,68,69,70,71],[65,66,67,69,71,72,73,74,75,76,77],[65,67,72],[66,67,72],[78,80],[80,81],[79,81],[78],[81]],"referencedMap":[[68,1],[73,1],[69,1],[67,2],[70,1],[71,1],[74,1],[75,1],[76,1],[77,1],[72,3],[78,4],[66,5],[65,6],[81,7],[82,8],[80,9]],"exportedModulesMap":[[68,1],[73,1],[69,1],[67,2],[70,1],[71,1],[74,1],[75,1],[76,1],[77,1],[72,3],[78,4],[66,5],[65,6],[81,10],[82,8],[80,11]],"semanticDiagnosticsPerFile":[68,73,69,67,70,71,74,75,76,77,72,78,66,65,63,64,12,14,13,2,15,16,17,18,19,20,21,22,3,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,11,62,61,60,81,82,80,79]},"version":"5.3.3"}
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/typescript/lib/lib.es2023.d.ts","../node_modules/typescript/lib/lib.esnext.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/typescript/lib/lib.es2023.array.d.ts","../node_modules/typescript/lib/lib.es2023.collection.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.esnext.disposable.d.ts","../node_modules/typescript/lib/lib.esnext.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/toosoon-gui/lib/wrapper.d.ts","../node_modules/toosoon-gui/lib/types.d.ts","../node_modules/toosoon-gui/lib/controllers/controller.d.ts","../node_modules/toosoon-gui/lib/controllers/angle-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/color-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/coords-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/file-controller.d.ts","../node_modules/toosoon-gui/lib/gui.d.ts","../node_modules/toosoon-gui/lib/controllers/boolean-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/function-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/number-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/option-controller.d.ts","../node_modules/toosoon-gui/lib/controllers/string-controller.d.ts","../node_modules/toosoon-gui/lib/index.d.ts","../src/utils.ts","../src/prng.ts","../src/controllers.ts","../src/index.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc","1c0cdb8dc619bc549c3e5020643e7cf7ae7940058e8c7e5aefa5871b6d86f44b","bed7b7ba0eb5a160b69af72814b4dde371968e40b6c5e73d3a9f7bee407d158c",{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"08a58483392df5fcc1db57d782e87734f77ae9eab42516028acbfe46f29a3ef7","affectsGlobalScope":true},{"version":"436aaf437562f276ec2ddbee2f2cdedac7664c1e4c1d2c36839ddd582eeb3d0a","affectsGlobalScope":true},{"version":"13f6e6380c78e15e140243dc4be2fa546c287c6d61f4729bc2dd7cf449605471","affectsGlobalScope":true},{"version":"4350e5922fecd4bedda2964d69c213a1436349d0b8d260dd902795f5b94dc74b","affectsGlobalScope":true},{"version":"d4b1d2c51d058fc21ec2629fff7a76249dec2e36e12960ea056e3ef89174080f","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"7f3b56b751819dfc3d25393d8232f400b8cbef152423e71d1e4e5db81cf2e2db","f7e25ae88d386440b751e25f12ec98bdd80822c54e58ed3cb80cc306ae9510e6","32c3a14e4806136096ba2da0c5101889803156a384c25c81d67e872e3be0d3ba","6339a44514a06c5e8f726cf27fc7fb2bf0e2ce5fe0de5545e4d412ba54c209f9","52800b74e97d62cd27f91a19ace28ca7ed32084fc5de80b015c8b62aabb4de99","2eba4de3285ccf1518aa5d87c683e4c4da38a837f69e112710fb107c58e86b9f","7b1267119c9c7c148ee973f8affd943c49f7ec2f5573f83cee25139492b533cd","3c73521cd265c18ed3aca9460bf298e5ed4a147aa3340f30ad7f1d9be05f726b","027d78906c03890d8473731baca3acad76095aa2e68af1c6fcd32ded61d9a430","5eb3db8ef1b8f4eb5b16facea0a1cc3d9c22d6513de77a29c6630233c7ccf888","448bf4331abf7995b2ab5c4a449800e35fc3dbcfb522ed752d84564fd7d17374","3147a65dfdc1827b3a1b3899c5b316e8cc10eeb66f5c26c758bb24b2c962983a","845075e15760edf65e31220cbfc67b0bd436be0cd169181aa524dcf8987ff09e","74427eecc65d24613d8483cb6191d32cb91aa79c2b13084ed2062457e3aa0376",{"version":"26e0b25ad701a5e58597ed82fa62f614efdb387d64597dfbaedf12898786dbd8","signature":"53ec1445b996aa4171b310f7fae307365d18c4a2d140002f499fa3ae3a354122"},{"version":"0f79b0456e9e64ee7d7c17218de9ff8285d2a91fed26103f62fd217cdfcbc74f","signature":"c0c499dc868ff11346ebba826f105635343f7fbdd2005cfe31158b12e725e502"},{"version":"afed0880319d48732105dcd665a9f4dcfa1a46b5ed644a5db3aa7b7f5ec09d68","signature":"273b0b65a6f4847bdc73d02fcf48febd9eb46892c988971b8fe7c4e7a8bbe4db"},{"version":"bb84c9b187526b2cc94af6bbd4c1255948d40c6be98d9f0908e3c0bf792c26c5","signature":"f57e602e7f0e41b3be4ddc07ca7a4095ad6964a05c53aad69aa0cb931f7b9e4d"}],"root":[[79,82]],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":true,"experimentalDecorators":true,"module":99,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","skipLibCheck":true,"strict":true,"target":1},"fileIdsList":[[67,72],[66,72],[66,67,68,69,70,71],[65,66,67,69,71,72,73,74,75,76,77],[65,67,72],[66,67,72],[78,80],[80,81],[79,81],[78],[81]],"referencedMap":[[68,1],[73,1],[69,1],[67,2],[70,1],[71,1],[74,1],[75,1],[76,1],[77,1],[72,3],[78,4],[66,5],[65,6],[81,7],[82,8],[80,9]],"exportedModulesMap":[[68,1],[73,1],[69,1],[67,2],[70,1],[71,1],[74,1],[75,1],[76,1],[77,1],[72,3],[78,4],[66,5],[65,6],[81,10],[82,8],[80,11]],"semanticDiagnosticsPerFile":[68,73,69,67,70,71,74,75,76,77,72,78,66,65,63,64,12,14,13,2,15,16,17,18,19,20,21,22,3,4,23,27,24,25,26,28,29,30,5,31,32,33,34,6,38,35,36,37,39,7,40,45,46,41,42,43,44,8,50,47,48,49,51,9,52,53,54,57,55,56,58,59,10,1,11,62,61,60,81,82,80,79]},"version":"5.3.3"}
package/lib/utils.d.ts CHANGED
@@ -12,27 +12,34 @@ export declare function cyrb128(seed: string): number[];
12
12
  * @param {number} b
13
13
  * @param {number} c
14
14
  * @param {number} d
15
- * @return {Function}
15
+ * @return {number}
16
16
  */
17
17
  export declare function sfc32(a: number, b: number, c: number, d: number): number;
18
+ /**
19
+ * SplitMix32, Generator with a 32-bit state
20
+ *
21
+ * @param {number} a
22
+ * @returns {number}
23
+ */
24
+ export declare function splitmix32(a: number): number;
18
25
  /**
19
26
  * Mulberry32, Generator with a 32-bit state
20
27
  *
21
28
  * @param {number} a
22
- * @return {Function}
29
+ * @return {number}
23
30
  */
24
31
  export declare function mulberry32(a: number): number;
25
32
  /**
26
33
  * Jenkins' Small Fast, Generator with a 32-bit state
27
34
  *
28
35
  * @param {number} a
29
- * @return {Function}
36
+ * @returns {number}
30
37
  */
31
38
  export declare function jsf32(a: number, b: number, c: number, d: number): number;
32
39
  /**
33
40
  * xoshiro128**, Generator with a 128-bit state
34
41
  *
35
42
  * @param {number} a
36
- * @return {Function}
43
+ * @returns {number}
37
44
  */
38
45
  export declare function xoshiro128ss(a: number, b: number, c: number, d: number): number;
package/lib/utils.js CHANGED
@@ -1,15 +1,12 @@
1
- "use strict";
2
1
  // Seeding random number generator
3
2
  // https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.xoshiro128ss = exports.jsf32 = exports.mulberry32 = exports.sfc32 = exports.cyrb128 = void 0;
6
3
  /**
7
4
  * Produce a 128-bit hash value from a string
8
5
  *
9
6
  * @param {string} seed
10
7
  * @return {number}
11
8
  */
12
- function cyrb128(seed) {
9
+ export function cyrb128(seed) {
13
10
  var h1 = 1779033703;
14
11
  var h2 = 3144134277;
15
12
  var h3 = 1013904242;
@@ -27,10 +24,9 @@ function cyrb128(seed) {
27
24
  h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);
28
25
  return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];
29
26
  }
30
- exports.cyrb128 = cyrb128;
31
- // ******************************************
32
- // Pseudo-random Number Generator
33
- // ******************************************
27
+ // *********************
28
+ // Algorithms
29
+ // *********************
34
30
  /**
35
31
  * Simple Fast Counter, Generator with a 128-bit state
36
32
  *
@@ -38,9 +34,9 @@ exports.cyrb128 = cyrb128;
38
34
  * @param {number} b
39
35
  * @param {number} c
40
36
  * @param {number} d
41
- * @return {Function}
37
+ * @return {number}
42
38
  */
43
- function sfc32(a, b, c, d) {
39
+ export function sfc32(a, b, c, d) {
44
40
  a >>>= 0;
45
41
  b >>>= 0;
46
42
  c >>>= 0;
@@ -54,27 +50,40 @@ function sfc32(a, b, c, d) {
54
50
  c = (c + t) | 0;
55
51
  return (t >>> 0) / 4294967296;
56
52
  }
57
- exports.sfc32 = sfc32;
53
+ /**
54
+ * SplitMix32, Generator with a 32-bit state
55
+ *
56
+ * @param {number} a
57
+ * @returns {number}
58
+ */
59
+ export function splitmix32(a) {
60
+ a |= 0;
61
+ a = (a + 0x9e3779b9) | 0;
62
+ var t = a ^ (a >>> 16);
63
+ t = Math.imul(t, 0x21f0aaad);
64
+ t = t ^ (t >>> 15);
65
+ t = Math.imul(t, 0x735a2d97);
66
+ return ((t = t ^ (t >>> 15)) >>> 0) / 4294967296;
67
+ }
58
68
  /**
59
69
  * Mulberry32, Generator with a 32-bit state
60
70
  *
61
71
  * @param {number} a
62
- * @return {Function}
72
+ * @return {number}
63
73
  */
64
- function mulberry32(a) {
74
+ export function mulberry32(a) {
65
75
  var t = (a += 0x6d2b79f5);
66
76
  t = Math.imul(t ^ (t >>> 15), t | 1);
67
77
  t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
68
78
  return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
69
79
  }
70
- exports.mulberry32 = mulberry32;
71
80
  /**
72
81
  * Jenkins' Small Fast, Generator with a 32-bit state
73
82
  *
74
83
  * @param {number} a
75
- * @return {Function}
84
+ * @returns {number}
76
85
  */
77
- function jsf32(a, b, c, d) {
86
+ export function jsf32(a, b, c, d) {
78
87
  a |= 0;
79
88
  b |= 0;
80
89
  c |= 0;
@@ -86,14 +95,13 @@ function jsf32(a, b, c, d) {
86
95
  d = (a + t) | 0;
87
96
  return (d >>> 0) / 4294967296;
88
97
  }
89
- exports.jsf32 = jsf32;
90
98
  /**
91
99
  * xoshiro128**, Generator with a 128-bit state
92
100
  *
93
101
  * @param {number} a
94
- * @return {Function}
102
+ * @returns {number}
95
103
  */
96
- function xoshiro128ss(a, b, c, d) {
104
+ export function xoshiro128ss(a, b, c, d) {
97
105
  var t = b << 9;
98
106
  var r = a * 5;
99
107
  r = ((r << 7) | (r >>> 25)) * 9;
@@ -105,4 +113,3 @@ function xoshiro128ss(a, b, c, d) {
105
113
  d = (d << 11) | (d >>> 21);
106
114
  return (r >>> 0) / 4294967296;
107
115
  }
108
- exports.xoshiro128ss = xoshiro128ss;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toosoon-prng",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "description": "Pseudo-random number generator utility functions & controllers",
5
5
  "main": "./lib/index.js",
6
6
  "scripts": {
@@ -14,7 +14,11 @@
14
14
  "keywords": [
15
15
  "tooson",
16
16
  "prng",
17
- "random"
17
+ "pseudo-random",
18
+ "random",
19
+ "randomization",
20
+ "procedural",
21
+ "generative"
18
22
  ],
19
23
  "author": "Arnaud Rocca",
20
24
  "license": "MIT",
@@ -23,7 +27,7 @@
23
27
  },
24
28
  "homepage": "https://github.com/toosoon-dev/toosoon-prng#readme",
25
29
  "dependencies": {
26
- "toosoon-gui": "^1.0.6"
30
+ "toosoon-gui": "^1.2.1"
27
31
  },
28
32
  "devDependencies": {
29
33
  "typescript": "^5.3.3"
@@ -1,18 +1,18 @@
1
- import type { Gui, GuiController } from 'toosoon-gui';
1
+ import { Gui, GuiController } from 'toosoon-gui';
2
2
 
3
3
  import prng from './prng';
4
4
 
5
5
  export interface PRNGController<T = unknown> {
6
6
  seed: string;
7
7
  value: T;
8
- addGui(gui: Gui, min?: number, max?: number, step?: number): GuiController;
8
+ addGUI(gui: Gui, min?: number, max?: number, step?: number): GuiController;
9
9
  getValue(): T;
10
10
  dispose(): void;
11
11
  }
12
12
 
13
13
  export interface PRNGGroupController<T = unknown> {
14
14
  seed: string;
15
- addGui(gui: Gui, min?: number, max?: number, step?: number): Gui;
15
+ addGUI(gui: Gui, min?: number, max?: number, step?: number): Gui;
16
16
  createController(index: number): PRNGController<T>;
17
17
  getValueAt(index: number): T;
18
18
  dispose(): void;
@@ -31,7 +31,7 @@ abstract class BasePRNGController<T> implements PRNGController<T> {
31
31
  prng.addController(this);
32
32
  }
33
33
 
34
- abstract addGui(gui: Gui, min?: number, max?: number, step?: number): GuiController;
34
+ abstract addGUI(gui: Gui, min?: number, max?: number, step?: number): GuiController;
35
35
 
36
36
  abstract getValue(): T;
37
37
 
@@ -55,7 +55,7 @@ abstract class BasePRNGGroupController<T> implements PRNGGroupController<T> {
55
55
  this.seed = seed;
56
56
  }
57
57
 
58
- addGui(gui: Gui, min?: number, max?: number, step?: number) {
58
+ addGUI(gui: Gui, min?: number, max?: number, step?: number) {
59
59
  this.gui = gui.addFolder(this.seed).close();
60
60
  this.guiArgs = { min, max, step };
61
61
  return this.gui;
@@ -69,7 +69,7 @@ abstract class BasePRNGGroupController<T> implements PRNGGroupController<T> {
69
69
  controller = this.createController(index);
70
70
  if (this.gui) {
71
71
  controller
72
- .addGui(this.gui, this.guiArgs.min, this.guiArgs.max, this.guiArgs.step)
72
+ .addGUI(this.gui, this.guiArgs.min, this.guiArgs.max, this.guiArgs.step)
73
73
  .name(`${this.seed}-${index}`);
74
74
  }
75
75
  this.controllers[index] = controller;
@@ -98,7 +98,7 @@ export class BooleanController extends BasePRNGController<boolean> {
98
98
  this.value = this.getValue();
99
99
  }
100
100
 
101
- addGui(gui: Gui) {
101
+ addGUI(gui: Gui) {
102
102
  this.gui = gui.add(this, 'value').name(this.seed);
103
103
  return this.gui;
104
104
  }
@@ -121,7 +121,7 @@ export class SignController extends BasePRNGController<number> {
121
121
  this.value = this.getValue();
122
122
  }
123
123
 
124
- addGui(gui: Gui) {
124
+ addGUI(gui: Gui) {
125
125
  this.gui = gui.add(this, 'value', [-1, 1]).name(this.seed);
126
126
  return this.gui;
127
127
  }
@@ -146,7 +146,7 @@ export class FloatController extends BasePRNGController<number> {
146
146
  this.value = this.getValue();
147
147
  }
148
148
 
149
- addGui(gui: Gui, min: number, max: number, step: number = 0.01) {
149
+ addGUI(gui: Gui, min: number, max: number, step: number = 0.01) {
150
150
  this.gui = gui.add(this, 'value', min, max, step).name(this.seed);
151
151
  return this.gui;
152
152
  }
@@ -171,7 +171,7 @@ export class IntController extends BasePRNGController<number> {
171
171
  this.value = prng.randomInt(this.seed, min, max);
172
172
  }
173
173
 
174
- addGui(gui: Gui, min: number, max: number, step = 1) {
174
+ addGUI(gui: Gui, min: number, max: number, step = 1) {
175
175
  this.gui = gui.add(this, 'value', min, max, step).name(this.seed);
176
176
  return this.gui;
177
177
  }
@@ -192,7 +192,7 @@ export class HexColorController extends BasePRNGController<string> {
192
192
  this.value = this.getValue();
193
193
  }
194
194
 
195
- addGui(gui: Gui) {
195
+ addGUI(gui: Gui) {
196
196
  this.gui = gui.addColor(this, 'value').name(this.seed);
197
197
  return this.gui;
198
198
  }
@@ -215,7 +215,7 @@ export class ItemController<T = unknown> extends BasePRNGController<T> {
215
215
  this.value = this.getValue();
216
216
  }
217
217
 
218
- addGui(gui: Gui) {
218
+ addGUI(gui: Gui) {
219
219
  this.gui = gui.add(this, 'value', this.items).name(this.seed);
220
220
  return this.gui;
221
221
  }
@@ -238,7 +238,7 @@ export class ObjectPropertyController<T = unknown> extends BasePRNGController<T>
238
238
  this.value = this.getValue();
239
239
  }
240
240
 
241
- addGui(gui: Gui) {
241
+ addGUI(gui: Gui) {
242
242
  this.gui = gui.add(this, 'value', this.object).name(this.seed);
243
243
  return this.gui;
244
244
  }
@@ -265,7 +265,7 @@ export class WeightsController<T = unknown> extends BasePRNGController<T> {
265
265
  this.value = this.getValue();
266
266
  }
267
267
 
268
- addGui(gui: Gui) {
268
+ addGUI(gui: Gui) {
269
269
  this.gui = gui
270
270
  .add(
271
271
  this,
package/src/index.ts CHANGED
@@ -18,5 +18,4 @@ export {
18
18
  } from './controllers';
19
19
  export type { PRNGController, PRNGGroupController } from './controllers';
20
20
 
21
- export { default } from './prng';
22
- export type * from './prng';
21
+ export { default, Algorithm } from './prng';