@jaypie/fabricator 0.2.0 → 0.3.0
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/dist/Fabricator.d.ts +2 -41
- package/dist/WorldFabricator.d.ts +0 -5
- package/dist/index.js +579 -683
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,245 +1,121 @@
|
|
|
1
|
-
import { Faker as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
return typeof
|
|
1
|
+
import { Faker as G, en as P } from "@faker-js/faker";
|
|
2
|
+
const z = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
3
|
+
function K(r) {
|
|
4
|
+
return typeof r == "string" && z.test(r);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
if (!
|
|
6
|
+
function M(r) {
|
|
7
|
+
if (!K(r))
|
|
8
8
|
throw TypeError("Invalid UUID");
|
|
9
|
-
let
|
|
10
|
-
return Uint8Array.of((
|
|
9
|
+
let t;
|
|
10
|
+
return Uint8Array.of((t = parseInt(r.slice(0, 8), 16)) >>> 24, t >>> 16 & 255, t >>> 8 & 255, t & 255, (t = parseInt(r.slice(9, 13), 16)) >>> 8, t & 255, (t = parseInt(r.slice(14, 18), 16)) >>> 8, t & 255, (t = parseInt(r.slice(19, 23), 16)) >>> 8, t & 255, (t = parseInt(r.slice(24, 36), 16)) / 1099511627776 & 255, t / 4294967296 & 255, t >>> 24 & 255, t >>> 16 & 255, t >>> 8 & 255, t & 255);
|
|
11
11
|
}
|
|
12
|
-
const
|
|
13
|
-
for (let
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
return (
|
|
12
|
+
const R = [];
|
|
13
|
+
for (let r = 0; r < 256; ++r)
|
|
14
|
+
R.push((r + 256).toString(16).slice(1));
|
|
15
|
+
function X(r, t = 0) {
|
|
16
|
+
return (R[r[t + 0]] + R[r[t + 1]] + R[r[t + 2]] + R[r[t + 3]] + "-" + R[r[t + 4]] + R[r[t + 5]] + "-" + R[r[t + 6]] + R[r[t + 7]] + "-" + R[r[t + 8]] + R[r[t + 9]] + "-" + R[r[t + 10]] + R[r[t + 11]] + R[r[t + 12]] + R[r[t + 13]] + R[r[t + 14]] + R[r[t + 15]]).toLowerCase();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
for (let
|
|
22
|
-
e
|
|
23
|
-
return
|
|
18
|
+
function tt(r) {
|
|
19
|
+
r = unescape(encodeURIComponent(r));
|
|
20
|
+
const t = new Uint8Array(r.length);
|
|
21
|
+
for (let e = 0; e < r.length; ++e)
|
|
22
|
+
t[e] = r.charCodeAt(e);
|
|
23
|
+
return t;
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
if (typeof
|
|
25
|
+
const et = "6ba7b810-9dad-11d1-80b4-00c04fd430c8", rt = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
26
|
+
function nt(r, t, e, n, a, i) {
|
|
27
|
+
const u = typeof e == "string" ? tt(e) : e, c = typeof n == "string" ? M(n) : n;
|
|
28
|
+
if (typeof n == "string" && (n = M(n)), n?.length !== 16)
|
|
29
29
|
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
30
|
-
let
|
|
31
|
-
return
|
|
30
|
+
let o = new Uint8Array(16 + u.length);
|
|
31
|
+
return o.set(c), o.set(u, c.length), o = t(o), o[6] = o[6] & 15 | r, o[8] = o[8] & 63 | 128, X(o);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
switch (
|
|
33
|
+
function ot(r, t, e, n) {
|
|
34
|
+
switch (r) {
|
|
35
35
|
case 0:
|
|
36
|
-
return
|
|
36
|
+
return t & e ^ ~t & n;
|
|
37
37
|
case 1:
|
|
38
|
-
return
|
|
38
|
+
return t ^ e ^ n;
|
|
39
39
|
case 2:
|
|
40
|
-
return
|
|
40
|
+
return t & e ^ t & n ^ e & n;
|
|
41
41
|
case 3:
|
|
42
|
-
return
|
|
42
|
+
return t ^ e ^ n;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function S(r, t) {
|
|
46
|
+
return r << t | r >>> 32 - t;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
for (let
|
|
53
|
-
const
|
|
54
|
-
for (let
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
for (let
|
|
60
|
-
const
|
|
48
|
+
function it(r) {
|
|
49
|
+
const t = [1518500249, 1859775393, 2400959708, 3395469782], e = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], n = new Uint8Array(r.length + 1);
|
|
50
|
+
n.set(r), n[r.length] = 128, r = n;
|
|
51
|
+
const a = r.length / 4 + 2, i = Math.ceil(a / 16), u = new Array(i);
|
|
52
|
+
for (let c = 0; c < i; ++c) {
|
|
53
|
+
const o = new Uint32Array(16);
|
|
54
|
+
for (let E = 0; E < 16; ++E)
|
|
55
|
+
o[E] = r[c * 64 + E * 4] << 24 | r[c * 64 + E * 4 + 1] << 16 | r[c * 64 + E * 4 + 2] << 8 | r[c * 64 + E * 4 + 3];
|
|
56
|
+
u[c] = o;
|
|
57
|
+
}
|
|
58
|
+
u[i - 1][14] = (r.length - 1) * 8 / Math.pow(2, 32), u[i - 1][14] = Math.floor(u[i - 1][14]), u[i - 1][15] = (r.length - 1) * 8 & 4294967295;
|
|
59
|
+
for (let c = 0; c < i; ++c) {
|
|
60
|
+
const o = new Uint32Array(80);
|
|
61
61
|
for (let l = 0; l < 16; ++l)
|
|
62
|
-
|
|
62
|
+
o[l] = u[c][l];
|
|
63
63
|
for (let l = 16; l < 80; ++l)
|
|
64
|
-
|
|
65
|
-
let
|
|
64
|
+
o[l] = S(o[l - 3] ^ o[l - 8] ^ o[l - 14] ^ o[l - 16], 1);
|
|
65
|
+
let E = e[0], h = e[1], f = e[2], _ = e[3], m = e[4];
|
|
66
66
|
for (let l = 0; l < 80; ++l) {
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const g = Math.floor(l / 20), L = S(E, 5) + ot(g, h, f, _) + m + t[g] + o[l] >>> 0;
|
|
68
|
+
m = _, _ = f, f = S(h, 30) >>> 0, h = E, E = L;
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
e[0] = e[0] + E >>> 0, e[1] = e[1] + h >>> 0, e[2] = e[2] + f >>> 0, e[3] = e[3] + _ >>> 0, e[4] = e[4] + m >>> 0;
|
|
71
71
|
}
|
|
72
|
-
return Uint8Array.of(
|
|
72
|
+
return Uint8Array.of(e[0] >> 24, e[0] >> 16, e[0] >> 8, e[0], e[1] >> 24, e[1] >> 16, e[1] >> 8, e[1], e[2] >> 24, e[2] >> 16, e[2] >> 8, e[2], e[3] >> 24, e[3] >> 16, e[3] >> 8, e[3], e[4] >> 24, e[4] >> 16, e[4] >> 8, e[4]);
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
return
|
|
74
|
+
function U(r, t, e, n) {
|
|
75
|
+
return nt(80, it, r, t);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
BAD_GATEWAY: 502,
|
|
82
|
-
BAD_REQUEST: 400,
|
|
83
|
-
FORBIDDEN: 403,
|
|
84
|
-
GATEWAY_TIMEOUT: 504,
|
|
85
|
-
GONE: 410,
|
|
86
|
-
INTERNAL_ERROR: 500,
|
|
87
|
-
METHOD_NOT_ALLOWED: 405,
|
|
88
|
-
NOT_FOUND: 404,
|
|
89
|
-
TEAPOT: 418,
|
|
90
|
-
TOO_MANY_REQUESTS: 429,
|
|
91
|
-
UNAUTHORIZED: 401,
|
|
92
|
-
UNAVAILABLE: 503
|
|
93
|
-
}
|
|
94
|
-
}, a = {
|
|
95
|
-
MESSAGE: {
|
|
96
|
-
BAD_GATEWAY: "An unexpected error occurred on an upstream resource",
|
|
97
|
-
BAD_REQUEST: "The request was not properly formatted",
|
|
98
|
-
CONFIGURATION_ERROR: "The application responding to the request encountered a configuration error",
|
|
99
|
-
CORS_ERROR: "The requesting origin is not authorized to this resource",
|
|
100
|
-
FORBIDDEN: "Access to this resource is not authorized",
|
|
101
|
-
GATEWAY_TIMEOUT: "The connection timed out waiting for an upstream resource",
|
|
102
|
-
GONE: "The requested resource is no longer available",
|
|
103
|
-
ILLOGICAL: "The application encountered an illogical condition while processing the request",
|
|
104
|
-
INTERNAL_ERROR: "An unexpected error occurred and the request was unable to complete",
|
|
105
|
-
METHOD_NOT_ALLOWED: "The requested method is not allowed",
|
|
106
|
-
NOT_FOUND: "The requested resource was not found",
|
|
107
|
-
NOT_IMPLEMENTED: "The request was understood but the resource is not implemented",
|
|
108
|
-
REJECTED: "The request was rejected prior to processing",
|
|
109
|
-
TEAPOT: "This resource is a teapot incapable of processing the request",
|
|
110
|
-
TOO_MANY_REQUESTS: "The requesting origin exceeded the request limit",
|
|
111
|
-
UNAUTHORIZED: "The request did not include valid authentication credentials",
|
|
112
|
-
UNAVAILABLE: "The requested resource is temporarily unavailable",
|
|
113
|
-
UNHANDLED: "An unhandled error occurred and the request was unable to complete",
|
|
114
|
-
UNREACHABLE_CODE: "The application encountered an unreachable condition while processing the request"
|
|
115
|
-
},
|
|
116
|
-
TITLE: {
|
|
117
|
-
BAD_GATEWAY: "Bad Gateway",
|
|
118
|
-
BAD_REQUEST: "Bad Request",
|
|
119
|
-
CONFIGURATION_ERROR: "Internal Configuration Error",
|
|
120
|
-
CORS_ERROR: "Unauthorized Origin",
|
|
121
|
-
FORBIDDEN: "Forbidden",
|
|
122
|
-
GATEWAY_TIMEOUT: "Gateway Timeout",
|
|
123
|
-
GONE: "Gone",
|
|
124
|
-
INTERNAL_ERROR: "Internal Application Error",
|
|
125
|
-
METHOD_NOT_ALLOWED: "Method Not Allowed",
|
|
126
|
-
NOT_FOUND: "Not Found",
|
|
127
|
-
NOT_IMPLEMENTED: "Not Implemented",
|
|
128
|
-
REJECTED: "Request Rejected",
|
|
129
|
-
TEAPOT: "Teapot",
|
|
130
|
-
TOO_MANY_REQUESTS: "Too Many Requests",
|
|
131
|
-
UNAUTHORIZED: "Service Unauthorized",
|
|
132
|
-
UNAVAILABLE: "Service Unavailable"
|
|
133
|
-
},
|
|
134
|
-
TYPE: {
|
|
135
|
-
BAD_GATEWAY: "BAD_GATEWAY",
|
|
136
|
-
BAD_REQUEST: "BAD_REQUEST",
|
|
137
|
-
CONFIGURATION_ERROR: "CONFIGURATION_ERROR",
|
|
138
|
-
CORS_ERROR: "CORS_ERROR",
|
|
139
|
-
FORBIDDEN: "FORBIDDEN",
|
|
140
|
-
GATEWAY_TIMEOUT: "GATEWAY_TIMEOUT",
|
|
141
|
-
GONE: "GONE",
|
|
142
|
-
ILLOGICAL: "ILLOGICAL",
|
|
143
|
-
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
144
|
-
METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
|
|
145
|
-
NOT_FOUND: "NOT_FOUND",
|
|
146
|
-
NOT_IMPLEMENTED: "NOT_IMPLEMENTED",
|
|
147
|
-
REJECTED: "REJECTED",
|
|
148
|
-
TEAPOT: "TEAPOT",
|
|
149
|
-
TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS",
|
|
150
|
-
UNAUTHORIZED: "UNAUTHORIZED",
|
|
151
|
-
UNAVAILABLE: "UNAVAILABLE",
|
|
152
|
-
UNHANDLED: "UNHANDLED",
|
|
153
|
-
UNKNOWN_TYPE: "UNKNOWN_TYPE",
|
|
154
|
-
UNREACHABLE_CODE: "UNREACHABLE_CODE"
|
|
155
|
-
}
|
|
156
|
-
}, ae = "JaypieError";
|
|
157
|
-
class ue extends Error {
|
|
158
|
-
constructor(e = a.MESSAGE.INTERNAL_ERROR, { status: t = _.CODE.INTERNAL_ERROR, title: r = a.TITLE.INTERNAL_ERROR } = {}, { _type: E = a.TYPE.UNKNOWN_TYPE } = {}) {
|
|
159
|
-
super(e), this.title = r, this.detail = e, this.status = t, this.name = ae, this.isProjectError = !0, this.isJaypieError = !0, this._type = E, this.body = () => ({
|
|
160
|
-
errors: [
|
|
161
|
-
{
|
|
162
|
-
status: this.status,
|
|
163
|
-
title: this.title,
|
|
164
|
-
detail: this.detail
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
}), this.json = () => ({
|
|
168
|
-
status: this.status,
|
|
169
|
-
title: this.title,
|
|
170
|
-
detail: this.detail
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const Ee = {
|
|
175
|
-
apply: (n, e, t) => new n(...t)
|
|
176
|
-
};
|
|
177
|
-
function A(n, e, t, r) {
|
|
178
|
-
return new Proxy(class extends ue {
|
|
179
|
-
constructor(E = n) {
|
|
180
|
-
super(E, { status: e, title: t }, { _type: r });
|
|
181
|
-
}
|
|
182
|
-
}, Ee);
|
|
183
|
-
}
|
|
184
|
-
A(a.MESSAGE.BAD_GATEWAY, _.CODE.BAD_GATEWAY, a.TITLE.BAD_GATEWAY, a.TYPE.BAD_GATEWAY);
|
|
185
|
-
A(a.MESSAGE.BAD_REQUEST, _.CODE.BAD_REQUEST, a.TITLE.BAD_REQUEST, a.TYPE.BAD_REQUEST);
|
|
186
|
-
A(a.MESSAGE.FORBIDDEN, _.CODE.FORBIDDEN, a.TITLE.FORBIDDEN, a.TYPE.FORBIDDEN);
|
|
187
|
-
A(a.MESSAGE.GATEWAY_TIMEOUT, _.CODE.GATEWAY_TIMEOUT, a.TITLE.GATEWAY_TIMEOUT, a.TYPE.GATEWAY_TIMEOUT);
|
|
188
|
-
A(a.MESSAGE.GONE, _.CODE.GONE, a.TITLE.GONE, a.TYPE.GONE);
|
|
189
|
-
A(a.MESSAGE.INTERNAL_ERROR, _.CODE.INTERNAL_ERROR, a.TITLE.INTERNAL_ERROR, a.TYPE.INTERNAL_ERROR);
|
|
190
|
-
A(a.MESSAGE.METHOD_NOT_ALLOWED, _.CODE.METHOD_NOT_ALLOWED, a.TITLE.METHOD_NOT_ALLOWED, a.TYPE.METHOD_NOT_ALLOWED);
|
|
191
|
-
A(a.MESSAGE.NOT_FOUND, _.CODE.NOT_FOUND, a.TITLE.NOT_FOUND, a.TYPE.NOT_FOUND);
|
|
192
|
-
A(a.MESSAGE.TEAPOT, _.CODE.TEAPOT, a.TITLE.TEAPOT, a.TYPE.TEAPOT);
|
|
193
|
-
A(a.MESSAGE.TOO_MANY_REQUESTS, _.CODE.TOO_MANY_REQUESTS, a.TITLE.TOO_MANY_REQUESTS, a.TYPE.TOO_MANY_REQUESTS);
|
|
194
|
-
A(a.MESSAGE.UNAUTHORIZED, _.CODE.UNAUTHORIZED, a.TITLE.UNAUTHORIZED, a.TYPE.UNAUTHORIZED);
|
|
195
|
-
A(a.MESSAGE.UNAVAILABLE, _.CODE.UNAVAILABLE, a.TITLE.UNAVAILABLE, a.TYPE.UNAVAILABLE);
|
|
196
|
-
const x = A(a.MESSAGE.CONFIGURATION_ERROR, _.CODE.INTERNAL_ERROR, a.TITLE.CONFIGURATION_ERROR, a.TYPE.CONFIGURATION_ERROR);
|
|
197
|
-
A(a.MESSAGE.CORS_ERROR, _.CODE.UNAUTHORIZED, a.TITLE.CORS_ERROR, a.TYPE.CORS_ERROR);
|
|
198
|
-
A(a.MESSAGE.ILLOGICAL, _.CODE.INTERNAL_ERROR, a.TITLE.INTERNAL_ERROR, a.TYPE.ILLOGICAL);
|
|
199
|
-
A(a.MESSAGE.NOT_IMPLEMENTED, _.CODE.BAD_REQUEST, a.TITLE.NOT_IMPLEMENTED, a.TYPE.NOT_IMPLEMENTED);
|
|
200
|
-
A(a.MESSAGE.REJECTED, _.CODE.FORBIDDEN, a.TITLE.REJECTED, a.TYPE.REJECTED);
|
|
201
|
-
A(a.MESSAGE.UNHANDLED, _.CODE.INTERNAL_ERROR, a.TITLE.INTERNAL_ERROR, a.TYPE.UNHANDLED);
|
|
202
|
-
A(a.MESSAGE.UNREACHABLE_CODE, _.CODE.INTERNAL_ERROR, a.TITLE.INTERNAL_ERROR, a.TYPE.UNREACHABLE_CODE);
|
|
203
|
-
function W(n) {
|
|
204
|
-
if (!n)
|
|
77
|
+
U.DNS = et;
|
|
78
|
+
U.URL = rt;
|
|
79
|
+
function H(r) {
|
|
80
|
+
if (!r)
|
|
205
81
|
return 0;
|
|
206
|
-
const
|
|
207
|
-
return parseInt(
|
|
82
|
+
const t = M(r), e = Array.from(t.slice(-6)).map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
83
|
+
return parseInt(e, 16);
|
|
208
84
|
}
|
|
209
|
-
const
|
|
210
|
-
function
|
|
211
|
-
return typeof
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
return (
|
|
85
|
+
const st = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
86
|
+
function v(r) {
|
|
87
|
+
return typeof r == "number" ? Math.abs(r) : st.test(r) ? H(r) : Math.abs(
|
|
88
|
+
r.split("").reduce((t, e) => {
|
|
89
|
+
const n = e.charCodeAt(0);
|
|
90
|
+
return (t << 5) - t + n | 0;
|
|
215
91
|
}, 0)
|
|
216
92
|
);
|
|
217
93
|
}
|
|
218
|
-
function
|
|
219
|
-
if (!
|
|
94
|
+
function at(r) {
|
|
95
|
+
if (!r)
|
|
220
96
|
return [0];
|
|
221
|
-
const
|
|
222
|
-
return Array.from(
|
|
97
|
+
const t = M(r);
|
|
98
|
+
return Array.from(t);
|
|
223
99
|
}
|
|
224
|
-
const
|
|
225
|
-
function
|
|
226
|
-
if (!
|
|
227
|
-
return [
|
|
100
|
+
const ut = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
101
|
+
function B(r) {
|
|
102
|
+
if (!ut.test(r))
|
|
103
|
+
return [v(r)];
|
|
228
104
|
try {
|
|
229
|
-
return
|
|
105
|
+
return at(r);
|
|
230
106
|
} catch {
|
|
231
107
|
try {
|
|
232
|
-
return [
|
|
108
|
+
return [H(r)];
|
|
233
109
|
} catch {
|
|
234
|
-
return [
|
|
110
|
+
return [v(r)];
|
|
235
111
|
}
|
|
236
112
|
}
|
|
237
113
|
}
|
|
238
|
-
var
|
|
239
|
-
},
|
|
240
|
-
constructor(
|
|
241
|
-
var
|
|
242
|
-
super(),
|
|
114
|
+
var Et = Object.defineProperty, ct = (r, t, e) => t in r ? Et(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e, O = (r, t, e) => ct(r, typeof t != "symbol" ? t + "" : t, e), w = class {
|
|
115
|
+
}, ft = class W extends w {
|
|
116
|
+
constructor(t) {
|
|
117
|
+
var e;
|
|
118
|
+
super(), O(this, "_name"), O(this, "_rngFn"), this._name = (e = t.name) != null ? e : "function", this._rngFn = t;
|
|
243
119
|
}
|
|
244
120
|
get name() {
|
|
245
121
|
return this._name;
|
|
@@ -248,56 +124,56 @@ var le = Object.defineProperty, Te = (n, e, t) => e in n ? le(n, e, { enumerable
|
|
|
248
124
|
return this._rngFn();
|
|
249
125
|
}
|
|
250
126
|
clone() {
|
|
251
|
-
return new
|
|
127
|
+
return new W(this._rngFn);
|
|
252
128
|
}
|
|
253
129
|
};
|
|
254
|
-
function
|
|
255
|
-
switch (typeof
|
|
130
|
+
function Y(r) {
|
|
131
|
+
switch (typeof r) {
|
|
256
132
|
case "object":
|
|
257
|
-
if (
|
|
258
|
-
return
|
|
133
|
+
if (r instanceof w)
|
|
134
|
+
return r;
|
|
259
135
|
break;
|
|
260
136
|
case "function":
|
|
261
|
-
return new
|
|
137
|
+
return new ft(r);
|
|
262
138
|
default:
|
|
263
|
-
return new
|
|
139
|
+
return new _t(r);
|
|
264
140
|
}
|
|
265
|
-
throw new Error(`invalid RNG seed or instance "${
|
|
141
|
+
throw new Error(`invalid RNG seed or instance "${r}"`);
|
|
266
142
|
}
|
|
267
|
-
function
|
|
268
|
-
var
|
|
269
|
-
const
|
|
270
|
-
let
|
|
271
|
-
for (;
|
|
272
|
-
|
|
273
|
-
return
|
|
143
|
+
function ht(r, t) {
|
|
144
|
+
var e;
|
|
145
|
+
const n = `${r}`;
|
|
146
|
+
let a = 0, i = 0;
|
|
147
|
+
for (; i < n.length; )
|
|
148
|
+
t[255 & i] = 255 & (a ^= ((e = t[255 & i]) != null ? e : 0) * 19) + n.charCodeAt(i++);
|
|
149
|
+
return t.length ? t : [0];
|
|
274
150
|
}
|
|
275
|
-
function
|
|
276
|
-
for (let
|
|
277
|
-
const
|
|
278
|
-
e
|
|
151
|
+
function $(r, t) {
|
|
152
|
+
for (let e = t.length - 1; e > 0; e -= 1) {
|
|
153
|
+
const n = Math.floor(r.next() * (e + 1)), a = t[e];
|
|
154
|
+
t[e] = t[n], t[n] = a;
|
|
279
155
|
}
|
|
280
156
|
}
|
|
281
|
-
function F(
|
|
282
|
-
var
|
|
283
|
-
const
|
|
284
|
-
for (let
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
return
|
|
157
|
+
function F(r, t, e) {
|
|
158
|
+
var n, a;
|
|
159
|
+
const i = /* @__PURE__ */ new Map(), u = t.length - 1, c = Array.from({ length: e });
|
|
160
|
+
for (let o = 0; o < e; o++) {
|
|
161
|
+
const E = u - o + 1, h = Math.floor(r.next() * E);
|
|
162
|
+
c[o] = t[(n = i.get(h)) != null ? n : h], i.set(h, (a = i.get(u - o)) != null ? a : u - o);
|
|
163
|
+
}
|
|
164
|
+
return c;
|
|
289
165
|
}
|
|
290
|
-
var
|
|
291
|
-
constructor(
|
|
292
|
-
super(),
|
|
293
|
-
const
|
|
294
|
-
this.i = 0, this.j = 0, this.S =
|
|
295
|
-
let
|
|
296
|
-
for (;
|
|
297
|
-
|
|
298
|
-
for (let
|
|
299
|
-
const
|
|
300
|
-
|
|
166
|
+
var lt = 281474976710656, Tt = 4503599627370496, At = 9007199254740992, _t = class q extends w {
|
|
167
|
+
constructor(t = crypto.randomUUID()) {
|
|
168
|
+
super(), O(this, "_seed"), O(this, "i"), O(this, "j"), O(this, "S"), this._seed = t;
|
|
169
|
+
const e = ht(t, []), n = [], a = e.length;
|
|
170
|
+
this.i = 0, this.j = 0, this.S = n;
|
|
171
|
+
let i = 0;
|
|
172
|
+
for (; i <= 255; )
|
|
173
|
+
n[i] = i++;
|
|
174
|
+
for (let u = 0, c = 0; u <= 255; u++) {
|
|
175
|
+
const o = n[u];
|
|
176
|
+
c = 255 & c + e[u % a] + o, n[u] = n[c], n[c] = o;
|
|
301
177
|
}
|
|
302
178
|
this.g(256);
|
|
303
179
|
}
|
|
@@ -305,27 +181,27 @@ var Re = 281474976710656, me = 4503599627370496, Ne = 9007199254740992, Oe = cla
|
|
|
305
181
|
return "arc4";
|
|
306
182
|
}
|
|
307
183
|
next() {
|
|
308
|
-
let
|
|
309
|
-
for (;
|
|
310
|
-
|
|
311
|
-
for (;
|
|
312
|
-
|
|
313
|
-
return (
|
|
314
|
-
}
|
|
315
|
-
g(
|
|
316
|
-
const { S:
|
|
317
|
-
let { i:
|
|
318
|
-
for (;
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
184
|
+
let t = this.g(6), e = lt, n = 0;
|
|
185
|
+
for (; t < Tt; )
|
|
186
|
+
t = (t + n) * 256, e *= 256, n = this.g(1);
|
|
187
|
+
for (; t >= At; )
|
|
188
|
+
t /= 2, e /= 2, n >>>= 1;
|
|
189
|
+
return (t + n) / e;
|
|
190
|
+
}
|
|
191
|
+
g(t) {
|
|
192
|
+
const { S: e } = this;
|
|
193
|
+
let { i: n, j: a } = this, i = 0;
|
|
194
|
+
for (; t--; ) {
|
|
195
|
+
n = 255 & n + 1;
|
|
196
|
+
const u = e[n];
|
|
197
|
+
e[a] = u, a = 255 & a + u, e[n] = e[a], i = i * 256 + e[255 & e[n] + u];
|
|
322
198
|
}
|
|
323
|
-
return this.i =
|
|
199
|
+
return this.i = n, this.j = a, i;
|
|
324
200
|
}
|
|
325
201
|
clone() {
|
|
326
|
-
return new
|
|
202
|
+
return new q(this._seed);
|
|
327
203
|
}
|
|
328
|
-
},
|
|
204
|
+
}, Rt = class j extends w {
|
|
329
205
|
get name() {
|
|
330
206
|
return "Math.random";
|
|
331
207
|
}
|
|
@@ -333,96 +209,96 @@ var Re = 281474976710656, me = 4503599627370496, Ne = 9007199254740992, Oe = cla
|
|
|
333
209
|
return Math.random();
|
|
334
210
|
}
|
|
335
211
|
clone() {
|
|
336
|
-
return new
|
|
212
|
+
return new j();
|
|
337
213
|
}
|
|
338
214
|
};
|
|
339
|
-
function
|
|
340
|
-
return new
|
|
215
|
+
function N(r) {
|
|
216
|
+
return new Ot(r);
|
|
341
217
|
}
|
|
342
|
-
var
|
|
343
|
-
constructor(
|
|
344
|
-
|
|
218
|
+
var Ot = class {
|
|
219
|
+
constructor(r) {
|
|
220
|
+
O(this, "n"), O(this, "isInt", () => {
|
|
345
221
|
if (Number.isInteger(this.n))
|
|
346
222
|
return this;
|
|
347
223
|
throw new Error(`Expected number to be an integer, got ${this.n}`);
|
|
348
|
-
}),
|
|
224
|
+
}), O(this, "isPositive", () => {
|
|
349
225
|
if (this.n > 0)
|
|
350
226
|
return this;
|
|
351
227
|
throw new Error(`Expected number to be positive, got ${this.n}`);
|
|
352
|
-
}),
|
|
353
|
-
if (this.n <
|
|
228
|
+
}), O(this, "lessThan", (t) => {
|
|
229
|
+
if (this.n < t)
|
|
354
230
|
return this;
|
|
355
|
-
throw new Error(`Expected number to be less than ${
|
|
356
|
-
}),
|
|
357
|
-
if (this.n <=
|
|
231
|
+
throw new Error(`Expected number to be less than ${t}, got ${this.n}`);
|
|
232
|
+
}), O(this, "lessThanOrEqual", (t) => {
|
|
233
|
+
if (this.n <= t)
|
|
358
234
|
return this;
|
|
359
235
|
throw new Error(
|
|
360
|
-
`Expected number to be less than or equal to ${
|
|
236
|
+
`Expected number to be less than or equal to ${t}, got ${this.n}`
|
|
361
237
|
);
|
|
362
|
-
}),
|
|
363
|
-
if (this.n >=
|
|
238
|
+
}), O(this, "greaterThanOrEqual", (t) => {
|
|
239
|
+
if (this.n >= t)
|
|
364
240
|
return this;
|
|
365
241
|
throw new Error(
|
|
366
|
-
`Expected number to be greater than or equal to ${
|
|
242
|
+
`Expected number to be greater than or equal to ${t}, got ${this.n}`
|
|
367
243
|
);
|
|
368
|
-
}),
|
|
369
|
-
if (this.n >
|
|
244
|
+
}), O(this, "greaterThan", (t) => {
|
|
245
|
+
if (this.n > t)
|
|
370
246
|
return this;
|
|
371
|
-
throw new Error(`Expected number to be greater than ${
|
|
372
|
-
}), this.n =
|
|
247
|
+
throw new Error(`Expected number to be greater than ${t}, got ${this.n}`);
|
|
248
|
+
}), this.n = r;
|
|
373
249
|
}
|
|
374
250
|
};
|
|
375
|
-
function
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
return () =>
|
|
251
|
+
function Nt(r, t = 1) {
|
|
252
|
+
N(t).isInt().isPositive();
|
|
253
|
+
const e = r.irwinHall(t);
|
|
254
|
+
return () => e() / t;
|
|
379
255
|
}
|
|
380
|
-
function
|
|
381
|
-
return
|
|
256
|
+
function gt(r, t = 0.5) {
|
|
257
|
+
return N(t).greaterThanOrEqual(0).lessThanOrEqual(1), () => Math.min(1, Math.floor(r.next() + t));
|
|
382
258
|
}
|
|
383
|
-
function
|
|
384
|
-
return
|
|
385
|
-
let
|
|
386
|
-
for (;
|
|
387
|
-
|
|
388
|
-
return
|
|
259
|
+
function dt(r, t = 1, e = 0.5) {
|
|
260
|
+
return N(t).isInt().isPositive(), N(e).greaterThanOrEqual(0).lessThan(1), () => {
|
|
261
|
+
let n = 0, a = 0;
|
|
262
|
+
for (; n++ < t; )
|
|
263
|
+
r.next() < e && a++;
|
|
264
|
+
return a;
|
|
389
265
|
};
|
|
390
266
|
}
|
|
391
|
-
function
|
|
392
|
-
return
|
|
267
|
+
function mt(r, t = 1) {
|
|
268
|
+
return N(t).isPositive(), () => -Math.log(1 - r.next()) / t;
|
|
393
269
|
}
|
|
394
|
-
function
|
|
395
|
-
|
|
396
|
-
const
|
|
397
|
-
return () => Math.floor(1 + Math.log(
|
|
270
|
+
function pt(r, t = 0.5) {
|
|
271
|
+
N(t).greaterThan(0).lessThan(1);
|
|
272
|
+
const e = 1 / Math.log(1 - t);
|
|
273
|
+
return () => Math.floor(1 + Math.log(r.next()) * e);
|
|
398
274
|
}
|
|
399
|
-
function
|
|
400
|
-
return
|
|
401
|
-
let
|
|
402
|
-
for (let
|
|
403
|
-
|
|
404
|
-
return
|
|
275
|
+
function It(r, t = 1) {
|
|
276
|
+
return N(t).isInt().greaterThanOrEqual(0), () => {
|
|
277
|
+
let e = 0;
|
|
278
|
+
for (let n = 0; n < t; ++n)
|
|
279
|
+
e += r.next();
|
|
280
|
+
return e;
|
|
405
281
|
};
|
|
406
282
|
}
|
|
407
|
-
function
|
|
408
|
-
const
|
|
409
|
-
return () => Math.exp(
|
|
283
|
+
function Dt(r, t = 0, e = 1) {
|
|
284
|
+
const n = r.normal(t, e);
|
|
285
|
+
return () => Math.exp(n());
|
|
410
286
|
}
|
|
411
|
-
function
|
|
287
|
+
function Mt(r, t = 0, e = 1) {
|
|
412
288
|
return () => {
|
|
413
|
-
let
|
|
289
|
+
let n, a, i;
|
|
414
290
|
do
|
|
415
|
-
|
|
416
|
-
while (!
|
|
417
|
-
return
|
|
291
|
+
n = r.next() * 2 - 1, a = r.next() * 2 - 1, i = n * n + a * a;
|
|
292
|
+
while (!i || i > 1);
|
|
293
|
+
return t + e * a * Math.sqrt(-2 * Math.log(i) / i);
|
|
418
294
|
};
|
|
419
295
|
}
|
|
420
|
-
function
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
return () => 1 / Math.pow(1 -
|
|
296
|
+
function Ut(r, t = 1) {
|
|
297
|
+
N(t).greaterThanOrEqual(0);
|
|
298
|
+
const e = 1 / t;
|
|
299
|
+
return () => 1 / Math.pow(1 - r.next(), e);
|
|
424
300
|
}
|
|
425
|
-
var
|
|
301
|
+
var wt = [
|
|
426
302
|
0,
|
|
427
303
|
0,
|
|
428
304
|
0.6931471805599453,
|
|
@@ -433,61 +309,61 @@ var ye = [
|
|
|
433
309
|
8.525161361065415,
|
|
434
310
|
10.60460290274525,
|
|
435
311
|
12.801827480081469
|
|
436
|
-
],
|
|
437
|
-
function
|
|
438
|
-
if (
|
|
439
|
-
const
|
|
312
|
+
], Lt = (r) => wt[r], bt = 0.9189385332046727;
|
|
313
|
+
function St(r, t = 1) {
|
|
314
|
+
if (N(t).isPositive(), t < 10) {
|
|
315
|
+
const e = Math.exp(-t);
|
|
440
316
|
return () => {
|
|
441
|
-
let
|
|
442
|
-
for (;
|
|
443
|
-
|
|
444
|
-
return
|
|
317
|
+
let n = e, a = 0, i = r.next();
|
|
318
|
+
for (; i > n; )
|
|
319
|
+
i = i - n, n = t * n / ++a;
|
|
320
|
+
return a;
|
|
445
321
|
};
|
|
446
322
|
} else {
|
|
447
|
-
const
|
|
323
|
+
const e = Math.sqrt(t), n = 0.931 + 2.53 * e, a = -0.059 + 0.02483 * n, i = 1.1239 + 1.1328 / (n - 3.4), u = 0.9277 - 3.6224 / (n - 2);
|
|
448
324
|
return () => {
|
|
449
|
-
for (var
|
|
450
|
-
let
|
|
451
|
-
if (
|
|
452
|
-
return
|
|
453
|
-
(2 *
|
|
325
|
+
for (var c; ; ) {
|
|
326
|
+
let o, E = r.next();
|
|
327
|
+
if (E <= 0.86 * u)
|
|
328
|
+
return o = E / u - 0.43, Math.floor(
|
|
329
|
+
(2 * a / (0.5 - Math.abs(o)) + n) * o + t + 0.445
|
|
454
330
|
);
|
|
455
|
-
|
|
456
|
-
const h = 0.5 - Math.abs(
|
|
457
|
-
if (h < 0.013 &&
|
|
331
|
+
E >= u ? o = r.next() - 0.5 : (o = E / u - 0.93, o = (o < 0 ? -0.5 : 0.5) - o, E = r.next() * u);
|
|
332
|
+
const h = 0.5 - Math.abs(o);
|
|
333
|
+
if (h < 0.013 && E > h)
|
|
458
334
|
continue;
|
|
459
|
-
const
|
|
460
|
-
if (
|
|
461
|
-
const
|
|
462
|
-
if (Math.log(
|
|
463
|
-
return
|
|
464
|
-
} else if (
|
|
465
|
-
const
|
|
466
|
-
if (Math.log(
|
|
467
|
-
return
|
|
335
|
+
const f = Math.floor((2 * a / h + n) * o + t + 0.445);
|
|
336
|
+
if (E = E * i / (a / (h * h) + n), f >= 10) {
|
|
337
|
+
const _ = (f + 0.5) * Math.log(t / f) - t - bt + f - (0.08333333333333333 - (0.002777777777777778 - 1 / (1260 * f * f)) / (f * f)) / f;
|
|
338
|
+
if (Math.log(E * e) <= _)
|
|
339
|
+
return f;
|
|
340
|
+
} else if (f >= 0) {
|
|
341
|
+
const _ = (c = Lt(f)) != null ? c : 0;
|
|
342
|
+
if (Math.log(E) <= f * Math.log(t) - t - _)
|
|
343
|
+
return f;
|
|
468
344
|
}
|
|
469
345
|
}
|
|
470
346
|
};
|
|
471
347
|
}
|
|
472
348
|
}
|
|
473
|
-
function
|
|
474
|
-
return () =>
|
|
349
|
+
function xt(r, t = 0, e = 1) {
|
|
350
|
+
return () => r.next() * (e - t) + t;
|
|
475
351
|
}
|
|
476
|
-
function
|
|
477
|
-
return () =>
|
|
352
|
+
function Ct(r) {
|
|
353
|
+
return () => r.next() >= 0.5;
|
|
478
354
|
}
|
|
479
|
-
function
|
|
480
|
-
return
|
|
355
|
+
function yt(r, t = 0, e = 1) {
|
|
356
|
+
return e === void 0 && (e = t === void 0 ? 1 : t, t = 0), N(t).isInt(), N(e).isInt(), () => Math.floor(r.next() * (e - t + 1) + t);
|
|
481
357
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
484
|
-
const
|
|
485
|
-
return
|
|
358
|
+
function Gt(r, t, e) {
|
|
359
|
+
return N(t).greaterThan(0), N(e).greaterThan(0), () => {
|
|
360
|
+
const n = 1 - r.next();
|
|
361
|
+
return t * Math.pow(-Math.log(n), 1 / e);
|
|
486
362
|
};
|
|
487
363
|
}
|
|
488
|
-
var
|
|
489
|
-
constructor(
|
|
490
|
-
|
|
364
|
+
var Pt = class Q {
|
|
365
|
+
constructor(t = new Rt()) {
|
|
366
|
+
O(this, "_rng"), O(this, "_cache", {}), this._rng = Y(t);
|
|
491
367
|
}
|
|
492
368
|
/**
|
|
493
369
|
* @member {RNG} rng - Underlying pseudo-random number generator.
|
|
@@ -499,8 +375,8 @@ var $e = class J {
|
|
|
499
375
|
* Creates a new `Random` instance, optionally specifying parameters to
|
|
500
376
|
* set a new seed.
|
|
501
377
|
*/
|
|
502
|
-
clone(
|
|
503
|
-
return new
|
|
378
|
+
clone(t = this.rng.clone()) {
|
|
379
|
+
return new Q(t);
|
|
504
380
|
}
|
|
505
381
|
/**
|
|
506
382
|
* Sets the underlying pseudorandom number generator.
|
|
@@ -514,8 +390,8 @@ var $e = class J {
|
|
|
514
390
|
* random.use(Math.random)
|
|
515
391
|
* ```
|
|
516
392
|
*/
|
|
517
|
-
use(
|
|
518
|
-
this._rng =
|
|
393
|
+
use(t) {
|
|
394
|
+
this._rng = Y(t), this._cache = {};
|
|
519
395
|
}
|
|
520
396
|
// --------------------------------------------------------------------------
|
|
521
397
|
// Uniform utility functions
|
|
@@ -539,8 +415,8 @@ var $e = class J {
|
|
|
539
415
|
* @param {number} [min=0] - Lower bound (float, inclusive)
|
|
540
416
|
* @param {number} [max=1] - Upper bound (float, exclusive)
|
|
541
417
|
*/
|
|
542
|
-
float(
|
|
543
|
-
return this.uniform(
|
|
418
|
+
float(t, e) {
|
|
419
|
+
return this.uniform(t, e)();
|
|
544
420
|
}
|
|
545
421
|
/**
|
|
546
422
|
* Samples a uniform random integer, optionally specifying lower and upper
|
|
@@ -551,8 +427,8 @@ var $e = class J {
|
|
|
551
427
|
* @param {number} [min=0] - Lower bound (integer, inclusive)
|
|
552
428
|
* @param {number} [max=1] - Upper bound (integer, inclusive)
|
|
553
429
|
*/
|
|
554
|
-
int(
|
|
555
|
-
return this.uniformInt(
|
|
430
|
+
int(t, e) {
|
|
431
|
+
return this.uniformInt(t, e)();
|
|
556
432
|
}
|
|
557
433
|
/**
|
|
558
434
|
* Samples a uniform random integer, optionally specifying lower and upper
|
|
@@ -565,8 +441,8 @@ var $e = class J {
|
|
|
565
441
|
* @param {number} [min=0] - Lower bound (integer, inclusive)
|
|
566
442
|
* @param {number} [max=1] - Upper bound (integer, inclusive)
|
|
567
443
|
*/
|
|
568
|
-
integer(
|
|
569
|
-
return this.uniformInt(
|
|
444
|
+
integer(t, e) {
|
|
445
|
+
return this.uniformInt(t, e)();
|
|
570
446
|
}
|
|
571
447
|
/**
|
|
572
448
|
* Samples a uniform random boolean value.
|
|
@@ -593,15 +469,15 @@ var $e = class J {
|
|
|
593
469
|
*
|
|
594
470
|
* @param {Array<T>} [array] - Input array
|
|
595
471
|
*/
|
|
596
|
-
choice(
|
|
597
|
-
if (!Array.isArray(
|
|
472
|
+
choice(t) {
|
|
473
|
+
if (!Array.isArray(t))
|
|
598
474
|
throw new TypeError(
|
|
599
|
-
`Random.choice expected input to be an array, got ${typeof
|
|
475
|
+
`Random.choice expected input to be an array, got ${typeof t}`
|
|
600
476
|
);
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
603
|
-
const
|
|
604
|
-
return
|
|
477
|
+
const e = t.length;
|
|
478
|
+
if (e > 0) {
|
|
479
|
+
const n = this.uniformInt(0, e - 1)();
|
|
480
|
+
return t[n];
|
|
605
481
|
} else
|
|
606
482
|
return;
|
|
607
483
|
}
|
|
@@ -610,16 +486,16 @@ var $e = class J {
|
|
|
610
486
|
*
|
|
611
487
|
* @param {Array<T>} [array] - Input array
|
|
612
488
|
*/
|
|
613
|
-
sample(
|
|
614
|
-
if (!Array.isArray(
|
|
489
|
+
sample(t, e) {
|
|
490
|
+
if (!Array.isArray(t))
|
|
615
491
|
throw new TypeError(
|
|
616
|
-
`Random.sample expected input to be an array, got ${typeof
|
|
492
|
+
`Random.sample expected input to be an array, got ${typeof t}`
|
|
617
493
|
);
|
|
618
|
-
if (
|
|
494
|
+
if (e < 0 || e > t.length)
|
|
619
495
|
throw new Error(
|
|
620
|
-
`Random.sample: k must be between 0 and array.length (${
|
|
496
|
+
`Random.sample: k must be between 0 and array.length (${t.length}), got ${e}`
|
|
621
497
|
);
|
|
622
|
-
return F(this.rng,
|
|
498
|
+
return F(this.rng, t, e);
|
|
623
499
|
}
|
|
624
500
|
/**
|
|
625
501
|
* Generates a thunk which returns samples of size k from the given array.
|
|
@@ -628,43 +504,43 @@ var $e = class J {
|
|
|
628
504
|
*
|
|
629
505
|
* @param {Array<T>} [array] - Input array
|
|
630
506
|
*/
|
|
631
|
-
sampler(
|
|
632
|
-
if (!Array.isArray(
|
|
507
|
+
sampler(t, e) {
|
|
508
|
+
if (!Array.isArray(t))
|
|
633
509
|
throw new TypeError(
|
|
634
|
-
`Random.sampler expected input to be an array, got ${typeof
|
|
510
|
+
`Random.sampler expected input to be an array, got ${typeof t}`
|
|
635
511
|
);
|
|
636
|
-
if (
|
|
512
|
+
if (e < 0 || e > t.length)
|
|
637
513
|
throw new Error(
|
|
638
|
-
`Random.sampler: k must be between 0 and array.length (${
|
|
514
|
+
`Random.sampler: k must be between 0 and array.length (${t.length}), got ${e}`
|
|
639
515
|
);
|
|
640
|
-
const
|
|
641
|
-
return () => F(
|
|
516
|
+
const n = this.rng;
|
|
517
|
+
return () => F(n, t, e);
|
|
642
518
|
}
|
|
643
519
|
/**
|
|
644
520
|
* Returns a shuffled copy of the given array.
|
|
645
521
|
*
|
|
646
522
|
* @param {Array<T>} [array] - Input array
|
|
647
523
|
*/
|
|
648
|
-
shuffle(
|
|
649
|
-
if (!Array.isArray(
|
|
524
|
+
shuffle(t) {
|
|
525
|
+
if (!Array.isArray(t))
|
|
650
526
|
throw new TypeError(
|
|
651
|
-
`Random.shuffle expected input to be an array, got ${typeof
|
|
527
|
+
`Random.shuffle expected input to be an array, got ${typeof t}`
|
|
652
528
|
);
|
|
653
|
-
const
|
|
654
|
-
return
|
|
529
|
+
const e = [...t];
|
|
530
|
+
return $(this.rng, e), e;
|
|
655
531
|
}
|
|
656
532
|
/**
|
|
657
533
|
* Generates a thunk which returns shuffled copies of the given array.
|
|
658
534
|
*
|
|
659
535
|
* @param {Array<T>} [array] - Input array
|
|
660
536
|
*/
|
|
661
|
-
shuffler(
|
|
662
|
-
if (!Array.isArray(
|
|
537
|
+
shuffler(t) {
|
|
538
|
+
if (!Array.isArray(t))
|
|
663
539
|
throw new TypeError(
|
|
664
|
-
`Random.shuffler expected input to be an array, got ${typeof
|
|
540
|
+
`Random.shuffler expected input to be an array, got ${typeof t}`
|
|
665
541
|
);
|
|
666
|
-
const
|
|
667
|
-
return () => (
|
|
542
|
+
const e = this.rng, n = [...t];
|
|
543
|
+
return () => ($(e, n), [...n]);
|
|
668
544
|
}
|
|
669
545
|
// --------------------------------------------------------------------------
|
|
670
546
|
// Uniform distributions
|
|
@@ -675,8 +551,8 @@ var $e = class J {
|
|
|
675
551
|
* @param {number} [min=0] - Lower bound (float, inclusive)
|
|
676
552
|
* @param {number} [max=1] - Upper bound (float, exclusive)
|
|
677
553
|
*/
|
|
678
|
-
uniform(
|
|
679
|
-
return this._memoize("uniform",
|
|
554
|
+
uniform(t, e) {
|
|
555
|
+
return this._memoize("uniform", xt, t, e);
|
|
680
556
|
}
|
|
681
557
|
/**
|
|
682
558
|
* Generates a [Discrete uniform distribution](https://en.wikipedia.org/wiki/Discrete_uniform_distribution).
|
|
@@ -684,8 +560,8 @@ var $e = class J {
|
|
|
684
560
|
* @param {number} [min=0] - Lower bound (integer, inclusive)
|
|
685
561
|
* @param {number} [max=1] - Upper bound (integer, inclusive)
|
|
686
562
|
*/
|
|
687
|
-
uniformInt(
|
|
688
|
-
return this._memoize("uniformInt",
|
|
563
|
+
uniformInt(t, e) {
|
|
564
|
+
return this._memoize("uniformInt", yt, t, e);
|
|
689
565
|
}
|
|
690
566
|
/**
|
|
691
567
|
* Generates a [Discrete uniform distribution](https://en.wikipedia.org/wiki/Discrete_uniform_distribution),
|
|
@@ -694,7 +570,7 @@ var $e = class J {
|
|
|
694
570
|
* This method is analogous to flipping a coin.
|
|
695
571
|
*/
|
|
696
572
|
uniformBoolean() {
|
|
697
|
-
return this._memoize("uniformBoolean",
|
|
573
|
+
return this._memoize("uniformBoolean", Ct);
|
|
698
574
|
}
|
|
699
575
|
// --------------------------------------------------------------------------
|
|
700
576
|
// Normal distributions
|
|
@@ -705,8 +581,8 @@ var $e = class J {
|
|
|
705
581
|
* @param {number} [mu=0] - Mean
|
|
706
582
|
* @param {number} [sigma=1] - Standard deviation
|
|
707
583
|
*/
|
|
708
|
-
normal(
|
|
709
|
-
return
|
|
584
|
+
normal(t, e) {
|
|
585
|
+
return Mt(this, t, e);
|
|
710
586
|
}
|
|
711
587
|
/**
|
|
712
588
|
* Generates a [Log-normal distribution](https://en.wikipedia.org/wiki/Log-normal_distribution).
|
|
@@ -714,8 +590,8 @@ var $e = class J {
|
|
|
714
590
|
* @param {number} [mu=0] - Mean of underlying normal distribution
|
|
715
591
|
* @param {number} [sigma=1] - Standard deviation of underlying normal distribution
|
|
716
592
|
*/
|
|
717
|
-
logNormal(
|
|
718
|
-
return
|
|
593
|
+
logNormal(t, e) {
|
|
594
|
+
return Dt(this, t, e);
|
|
719
595
|
}
|
|
720
596
|
// --------------------------------------------------------------------------
|
|
721
597
|
// Bernoulli distributions
|
|
@@ -725,8 +601,8 @@ var $e = class J {
|
|
|
725
601
|
*
|
|
726
602
|
* @param {number} [p=0.5] - Success probability of each trial.
|
|
727
603
|
*/
|
|
728
|
-
bernoulli(
|
|
729
|
-
return
|
|
604
|
+
bernoulli(t) {
|
|
605
|
+
return gt(this, t);
|
|
730
606
|
}
|
|
731
607
|
/**
|
|
732
608
|
* Generates a [Binomial distribution](https://en.wikipedia.org/wiki/Binomial_distribution).
|
|
@@ -734,16 +610,16 @@ var $e = class J {
|
|
|
734
610
|
* @param {number} [n=1] - Number of trials.
|
|
735
611
|
* @param {number} [p=0.5] - Success probability of each trial.
|
|
736
612
|
*/
|
|
737
|
-
binomial(
|
|
738
|
-
return
|
|
613
|
+
binomial(t, e) {
|
|
614
|
+
return dt(this, t, e);
|
|
739
615
|
}
|
|
740
616
|
/**
|
|
741
617
|
* Generates a [Geometric distribution](https://en.wikipedia.org/wiki/Geometric_distribution).
|
|
742
618
|
*
|
|
743
619
|
* @param {number} [p=0.5] - Success probability of each trial.
|
|
744
620
|
*/
|
|
745
|
-
geometric(
|
|
746
|
-
return
|
|
621
|
+
geometric(t) {
|
|
622
|
+
return pt(this, t);
|
|
747
623
|
}
|
|
748
624
|
// --------------------------------------------------------------------------
|
|
749
625
|
// Poisson distributions
|
|
@@ -753,16 +629,16 @@ var $e = class J {
|
|
|
753
629
|
*
|
|
754
630
|
* @param {number} [lambda=1] - Mean (lambda > 0)
|
|
755
631
|
*/
|
|
756
|
-
poisson(
|
|
757
|
-
return
|
|
632
|
+
poisson(t) {
|
|
633
|
+
return St(this, t);
|
|
758
634
|
}
|
|
759
635
|
/**
|
|
760
636
|
* Generates an [Exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution).
|
|
761
637
|
*
|
|
762
638
|
* @param {number} [lambda=1] - Inverse mean (lambda > 0)
|
|
763
639
|
*/
|
|
764
|
-
exponential(
|
|
765
|
-
return
|
|
640
|
+
exponential(t) {
|
|
641
|
+
return mt(this, t);
|
|
766
642
|
}
|
|
767
643
|
// --------------------------------------------------------------------------
|
|
768
644
|
// Misc distributions
|
|
@@ -772,24 +648,24 @@ var $e = class J {
|
|
|
772
648
|
*
|
|
773
649
|
* @param {number} [n=1] - Number of uniform samples to sum (n >= 0)
|
|
774
650
|
*/
|
|
775
|
-
irwinHall(
|
|
776
|
-
return
|
|
651
|
+
irwinHall(t) {
|
|
652
|
+
return It(this, t);
|
|
777
653
|
}
|
|
778
654
|
/**
|
|
779
655
|
* Generates a [Bates distribution](https://en.wikipedia.org/wiki/Bates_distribution).
|
|
780
656
|
*
|
|
781
657
|
* @param {number} [n=1] - Number of uniform samples to average (n >= 1)
|
|
782
658
|
*/
|
|
783
|
-
bates(
|
|
784
|
-
return
|
|
659
|
+
bates(t) {
|
|
660
|
+
return Nt(this, t);
|
|
785
661
|
}
|
|
786
662
|
/**
|
|
787
663
|
* Generates a [Pareto distribution](https://en.wikipedia.org/wiki/Pareto_distribution).
|
|
788
664
|
*
|
|
789
665
|
* @param {number} [alpha=1] - Alpha
|
|
790
666
|
*/
|
|
791
|
-
pareto(
|
|
792
|
-
return
|
|
667
|
+
pareto(t) {
|
|
668
|
+
return Ut(this, t);
|
|
793
669
|
}
|
|
794
670
|
/**
|
|
795
671
|
* Generates a [Weibull distribution](https://en.wikipedia.org/wiki/Weibull_distribution).
|
|
@@ -797,8 +673,8 @@ var $e = class J {
|
|
|
797
673
|
* @param {number} [lambda] - Lambda, the scale parameter
|
|
798
674
|
* @param {number} [k] - k, the shape parameter
|
|
799
675
|
*/
|
|
800
|
-
weibull(
|
|
801
|
-
return
|
|
676
|
+
weibull(t, e) {
|
|
677
|
+
return Gt(this, t, e);
|
|
802
678
|
}
|
|
803
679
|
// --------------------------------------------------------------------------
|
|
804
680
|
// Internal
|
|
@@ -815,94 +691,218 @@ var $e = class J {
|
|
|
815
691
|
* @param {function} getter - Function which generates a new distribution
|
|
816
692
|
* @param {...*} args - Distribution-specific arguments
|
|
817
693
|
*/
|
|
818
|
-
_memoize(
|
|
819
|
-
const
|
|
820
|
-
let
|
|
821
|
-
return (
|
|
822
|
-
key:
|
|
823
|
-
distribution:
|
|
824
|
-
}, this._cache[
|
|
825
|
-
}
|
|
826
|
-
},
|
|
827
|
-
const
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
694
|
+
_memoize(t, e, ...n) {
|
|
695
|
+
const a = `${n.join(";")}`;
|
|
696
|
+
let i = this._cache[t];
|
|
697
|
+
return (i === void 0 || i.key !== a) && (i = {
|
|
698
|
+
key: a,
|
|
699
|
+
distribution: e(this, ...n)
|
|
700
|
+
}, this._cache[t] = i), i.distribution;
|
|
701
|
+
}
|
|
702
|
+
}, k = new Pt();
|
|
703
|
+
const T = {
|
|
704
|
+
CODE: {
|
|
705
|
+
BAD_GATEWAY: 502,
|
|
706
|
+
BAD_REQUEST: 400,
|
|
707
|
+
FORBIDDEN: 403,
|
|
708
|
+
GATEWAY_TIMEOUT: 504,
|
|
709
|
+
GONE: 410,
|
|
710
|
+
INTERNAL_ERROR: 500,
|
|
711
|
+
METHOD_NOT_ALLOWED: 405,
|
|
712
|
+
NOT_FOUND: 404,
|
|
713
|
+
TEAPOT: 418,
|
|
714
|
+
TOO_MANY_REQUESTS: 429,
|
|
715
|
+
UNAUTHORIZED: 401,
|
|
716
|
+
UNAVAILABLE: 503
|
|
717
|
+
}
|
|
718
|
+
}, s = {
|
|
719
|
+
MESSAGE: {
|
|
720
|
+
BAD_GATEWAY: "An unexpected error occurred on an upstream resource",
|
|
721
|
+
BAD_REQUEST: "The request was not properly formatted",
|
|
722
|
+
CONFIGURATION_ERROR: "The application responding to the request encountered a configuration error",
|
|
723
|
+
CORS_ERROR: "The requesting origin is not authorized to this resource",
|
|
724
|
+
FORBIDDEN: "Access to this resource is not authorized",
|
|
725
|
+
GATEWAY_TIMEOUT: "The connection timed out waiting for an upstream resource",
|
|
726
|
+
GONE: "The requested resource is no longer available",
|
|
727
|
+
ILLOGICAL: "The application encountered an illogical condition while processing the request",
|
|
728
|
+
INTERNAL_ERROR: "An unexpected error occurred and the request was unable to complete",
|
|
729
|
+
METHOD_NOT_ALLOWED: "The requested method is not allowed",
|
|
730
|
+
NOT_FOUND: "The requested resource was not found",
|
|
731
|
+
NOT_IMPLEMENTED: "The request was understood but the resource is not implemented",
|
|
732
|
+
REJECTED: "The request was rejected prior to processing",
|
|
733
|
+
TEAPOT: "This resource is a teapot incapable of processing the request",
|
|
734
|
+
TOO_MANY_REQUESTS: "The requesting origin exceeded the request limit",
|
|
735
|
+
UNAUTHORIZED: "The request did not include valid authentication credentials",
|
|
736
|
+
UNAVAILABLE: "The requested resource is temporarily unavailable",
|
|
737
|
+
UNHANDLED: "An unhandled error occurred and the request was unable to complete",
|
|
738
|
+
UNREACHABLE_CODE: "The application encountered an unreachable condition while processing the request"
|
|
739
|
+
},
|
|
740
|
+
TITLE: {
|
|
741
|
+
BAD_GATEWAY: "Bad Gateway",
|
|
742
|
+
BAD_REQUEST: "Bad Request",
|
|
743
|
+
CONFIGURATION_ERROR: "Internal Configuration Error",
|
|
744
|
+
CORS_ERROR: "Unauthorized Origin",
|
|
745
|
+
FORBIDDEN: "Forbidden",
|
|
746
|
+
GATEWAY_TIMEOUT: "Gateway Timeout",
|
|
747
|
+
GONE: "Gone",
|
|
748
|
+
INTERNAL_ERROR: "Internal Application Error",
|
|
749
|
+
METHOD_NOT_ALLOWED: "Method Not Allowed",
|
|
750
|
+
NOT_FOUND: "Not Found",
|
|
751
|
+
NOT_IMPLEMENTED: "Not Implemented",
|
|
752
|
+
REJECTED: "Request Rejected",
|
|
753
|
+
TEAPOT: "Teapot",
|
|
754
|
+
TOO_MANY_REQUESTS: "Too Many Requests",
|
|
755
|
+
UNAUTHORIZED: "Service Unauthorized",
|
|
756
|
+
UNAVAILABLE: "Service Unavailable"
|
|
757
|
+
},
|
|
758
|
+
TYPE: {
|
|
759
|
+
BAD_GATEWAY: "BAD_GATEWAY",
|
|
760
|
+
BAD_REQUEST: "BAD_REQUEST",
|
|
761
|
+
CONFIGURATION_ERROR: "CONFIGURATION_ERROR",
|
|
762
|
+
CORS_ERROR: "CORS_ERROR",
|
|
763
|
+
FORBIDDEN: "FORBIDDEN",
|
|
764
|
+
GATEWAY_TIMEOUT: "GATEWAY_TIMEOUT",
|
|
765
|
+
GONE: "GONE",
|
|
766
|
+
ILLOGICAL: "ILLOGICAL",
|
|
767
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
768
|
+
METHOD_NOT_ALLOWED: "METHOD_NOT_ALLOWED",
|
|
769
|
+
NOT_FOUND: "NOT_FOUND",
|
|
770
|
+
NOT_IMPLEMENTED: "NOT_IMPLEMENTED",
|
|
771
|
+
REJECTED: "REJECTED",
|
|
772
|
+
TEAPOT: "TEAPOT",
|
|
773
|
+
TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS",
|
|
774
|
+
UNAUTHORIZED: "UNAUTHORIZED",
|
|
775
|
+
UNAVAILABLE: "UNAVAILABLE",
|
|
776
|
+
UNHANDLED: "UNHANDLED",
|
|
777
|
+
UNKNOWN_TYPE: "UNKNOWN_TYPE",
|
|
778
|
+
UNREACHABLE_CODE: "UNREACHABLE_CODE"
|
|
779
|
+
}
|
|
780
|
+
}, vt = "JaypieError";
|
|
781
|
+
class Bt extends Error {
|
|
782
|
+
constructor(t = s.MESSAGE.INTERNAL_ERROR, { status: e = T.CODE.INTERNAL_ERROR, title: n = s.TITLE.INTERNAL_ERROR } = {}, { _type: a = s.TYPE.UNKNOWN_TYPE } = {}) {
|
|
783
|
+
super(t), this.title = n, this.detail = t, this.status = e, this.name = vt, this.isProjectError = !0, this.isJaypieError = !0, this._type = a, this.body = () => ({
|
|
784
|
+
errors: [
|
|
785
|
+
{
|
|
786
|
+
status: this.status,
|
|
787
|
+
title: this.title,
|
|
788
|
+
detail: this.detail
|
|
789
|
+
}
|
|
790
|
+
]
|
|
791
|
+
}), this.json = () => ({
|
|
792
|
+
status: this.status,
|
|
793
|
+
title: this.title,
|
|
794
|
+
detail: this.detail
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
const Yt = {
|
|
799
|
+
apply: (r, t, e) => new r(...e)
|
|
800
|
+
};
|
|
801
|
+
function A(r, t, e, n) {
|
|
802
|
+
return new Proxy(class extends Bt {
|
|
803
|
+
constructor(a = r) {
|
|
804
|
+
super(a, { status: t, title: e }, { _type: n });
|
|
805
|
+
}
|
|
806
|
+
}, Yt);
|
|
807
|
+
}
|
|
808
|
+
A(s.MESSAGE.BAD_GATEWAY, T.CODE.BAD_GATEWAY, s.TITLE.BAD_GATEWAY, s.TYPE.BAD_GATEWAY);
|
|
809
|
+
A(s.MESSAGE.BAD_REQUEST, T.CODE.BAD_REQUEST, s.TITLE.BAD_REQUEST, s.TYPE.BAD_REQUEST);
|
|
810
|
+
A(s.MESSAGE.FORBIDDEN, T.CODE.FORBIDDEN, s.TITLE.FORBIDDEN, s.TYPE.FORBIDDEN);
|
|
811
|
+
A(s.MESSAGE.GATEWAY_TIMEOUT, T.CODE.GATEWAY_TIMEOUT, s.TITLE.GATEWAY_TIMEOUT, s.TYPE.GATEWAY_TIMEOUT);
|
|
812
|
+
A(s.MESSAGE.GONE, T.CODE.GONE, s.TITLE.GONE, s.TYPE.GONE);
|
|
813
|
+
A(s.MESSAGE.INTERNAL_ERROR, T.CODE.INTERNAL_ERROR, s.TITLE.INTERNAL_ERROR, s.TYPE.INTERNAL_ERROR);
|
|
814
|
+
A(s.MESSAGE.METHOD_NOT_ALLOWED, T.CODE.METHOD_NOT_ALLOWED, s.TITLE.METHOD_NOT_ALLOWED, s.TYPE.METHOD_NOT_ALLOWED);
|
|
815
|
+
A(s.MESSAGE.NOT_FOUND, T.CODE.NOT_FOUND, s.TITLE.NOT_FOUND, s.TYPE.NOT_FOUND);
|
|
816
|
+
A(s.MESSAGE.TEAPOT, T.CODE.TEAPOT, s.TITLE.TEAPOT, s.TYPE.TEAPOT);
|
|
817
|
+
A(s.MESSAGE.TOO_MANY_REQUESTS, T.CODE.TOO_MANY_REQUESTS, s.TITLE.TOO_MANY_REQUESTS, s.TYPE.TOO_MANY_REQUESTS);
|
|
818
|
+
A(s.MESSAGE.UNAUTHORIZED, T.CODE.UNAUTHORIZED, s.TITLE.UNAUTHORIZED, s.TYPE.UNAUTHORIZED);
|
|
819
|
+
A(s.MESSAGE.UNAVAILABLE, T.CODE.UNAVAILABLE, s.TITLE.UNAVAILABLE, s.TYPE.UNAVAILABLE);
|
|
820
|
+
const $t = A(s.MESSAGE.CONFIGURATION_ERROR, T.CODE.INTERNAL_ERROR, s.TITLE.CONFIGURATION_ERROR, s.TYPE.CONFIGURATION_ERROR);
|
|
821
|
+
A(s.MESSAGE.CORS_ERROR, T.CODE.UNAUTHORIZED, s.TITLE.CORS_ERROR, s.TYPE.CORS_ERROR);
|
|
822
|
+
A(s.MESSAGE.ILLOGICAL, T.CODE.INTERNAL_ERROR, s.TITLE.INTERNAL_ERROR, s.TYPE.ILLOGICAL);
|
|
823
|
+
A(s.MESSAGE.NOT_IMPLEMENTED, T.CODE.BAD_REQUEST, s.TITLE.NOT_IMPLEMENTED, s.TYPE.NOT_IMPLEMENTED);
|
|
824
|
+
A(s.MESSAGE.REJECTED, T.CODE.FORBIDDEN, s.TITLE.REJECTED, s.TYPE.REJECTED);
|
|
825
|
+
A(s.MESSAGE.UNHANDLED, T.CODE.INTERNAL_ERROR, s.TITLE.INTERNAL_ERROR, s.TYPE.UNHANDLED);
|
|
826
|
+
A(s.MESSAGE.UNREACHABLE_CODE, T.CODE.INTERNAL_ERROR, s.TITLE.INTERNAL_ERROR, s.TYPE.UNREACHABLE_CODE);
|
|
827
|
+
const Ft = 0, kt = 1, Ht = (r, t, e) => {
|
|
828
|
+
let n = r;
|
|
829
|
+
return typeof t == "number" && (n = Math.max(n, t)), typeof e == "number" && (n = Math.min(n, e)), n;
|
|
830
|
+
}, Wt = (r, t) => {
|
|
831
|
+
if (typeof r == "number" && typeof t == "number" && r > t)
|
|
832
|
+
throw new $t(
|
|
833
|
+
`Invalid bounds: min (${r}) cannot be greater than max (${t})`
|
|
834
834
|
);
|
|
835
835
|
};
|
|
836
|
-
function
|
|
837
|
-
const
|
|
836
|
+
function qt(r) {
|
|
837
|
+
const t = r !== void 0 ? String(r) : void 0, e = k.clone(t), n = /* @__PURE__ */ new Map();
|
|
838
838
|
return ({
|
|
839
|
-
min:
|
|
840
|
-
max:
|
|
841
|
-
mean:
|
|
842
|
-
stddev:
|
|
843
|
-
integer:
|
|
839
|
+
min: i,
|
|
840
|
+
max: u,
|
|
841
|
+
mean: c,
|
|
842
|
+
stddev: o,
|
|
843
|
+
integer: E = !1,
|
|
844
844
|
start: h = 0,
|
|
845
|
-
seed:
|
|
846
|
-
precision:
|
|
847
|
-
currency:
|
|
845
|
+
seed: f,
|
|
846
|
+
precision: _,
|
|
847
|
+
currency: m = !1
|
|
848
848
|
} = {}) => {
|
|
849
|
-
const l =
|
|
850
|
-
const
|
|
851
|
-
return
|
|
852
|
-
})() :
|
|
853
|
-
let
|
|
854
|
-
typeof
|
|
849
|
+
const l = f ? n.get(f) || (() => {
|
|
850
|
+
const d = k.clone(f);
|
|
851
|
+
return n.set(f, d), d;
|
|
852
|
+
})() : e;
|
|
853
|
+
let g = u;
|
|
854
|
+
typeof i == "number" && typeof g != "number" && (g = i * 2), Wt(i, g);
|
|
855
855
|
const L = () => {
|
|
856
|
-
if (
|
|
857
|
-
const
|
|
858
|
-
return typeof
|
|
859
|
-
},
|
|
860
|
-
const
|
|
861
|
-
if (typeof
|
|
862
|
-
const I = Math.pow(10,
|
|
863
|
-
return Math.round(
|
|
856
|
+
if (E) return 0;
|
|
857
|
+
const d = [];
|
|
858
|
+
return typeof _ == "number" && _ >= 0 && d.push(_), m && d.push(2), d.length > 0 ? Math.min(...d) : void 0;
|
|
859
|
+
}, b = (d) => {
|
|
860
|
+
const D = L();
|
|
861
|
+
if (typeof D == "number") {
|
|
862
|
+
const I = Math.pow(10, D);
|
|
863
|
+
return Math.round(d * I) / I;
|
|
864
864
|
}
|
|
865
|
-
return
|
|
865
|
+
return d;
|
|
866
866
|
};
|
|
867
|
-
if (typeof
|
|
868
|
-
const
|
|
869
|
-
if (typeof
|
|
870
|
-
const
|
|
871
|
-
return
|
|
867
|
+
if (typeof c == "number" && typeof o == "number") {
|
|
868
|
+
const D = l.normal(c, o)(), I = Ht(D, i, u);
|
|
869
|
+
if (typeof i == "number" && typeof u == "number" && I !== D) {
|
|
870
|
+
const Z = E ? l.int(i, g) : l.float(i, g);
|
|
871
|
+
return b(h + Z);
|
|
872
872
|
}
|
|
873
|
-
return
|
|
874
|
-
h + (
|
|
873
|
+
return b(
|
|
874
|
+
h + (E ? Math.round(I) : I)
|
|
875
875
|
);
|
|
876
876
|
}
|
|
877
|
-
const C = typeof
|
|
878
|
-
return
|
|
877
|
+
const C = typeof i == "number" ? i : Ft, y = typeof g == "number" ? g : kt, V = E ? l.int(C, y) : l.float(C, y);
|
|
878
|
+
return b(h + V);
|
|
879
879
|
};
|
|
880
880
|
}
|
|
881
|
-
const
|
|
882
|
-
function
|
|
883
|
-
return
|
|
881
|
+
const jt = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
882
|
+
function J(r) {
|
|
883
|
+
return jt.test(r);
|
|
884
884
|
}
|
|
885
|
-
const
|
|
885
|
+
const zt = {
|
|
886
886
|
UNCOMMON: 0.146,
|
|
887
887
|
RARE: 0.021,
|
|
888
888
|
EPIC: 307e-5,
|
|
889
889
|
LEGENDARY: 441e-6
|
|
890
|
-
},
|
|
891
|
-
function
|
|
892
|
-
const
|
|
893
|
-
return
|
|
894
|
-
`[uuidFrom] Input is already a UUID: ${
|
|
895
|
-
),
|
|
890
|
+
}, Qt = "345457ac-3414-4ae6-96d1-a16f12ae562f";
|
|
891
|
+
function Jt(r) {
|
|
892
|
+
const t = String(r);
|
|
893
|
+
return J(t) ? (console.warn(
|
|
894
|
+
`[uuidFrom] Input is already a UUID: ${t}. Returning input unchanged.`
|
|
895
|
+
), t) : U(t, Qt);
|
|
896
896
|
}
|
|
897
|
-
function
|
|
898
|
-
return
|
|
897
|
+
function Vt(r) {
|
|
898
|
+
return r.charAt(0).toUpperCase() + r.slice(1);
|
|
899
899
|
}
|
|
900
|
-
function
|
|
901
|
-
return
|
|
900
|
+
function x({ fabricator: r }) {
|
|
901
|
+
return r.generate.words().split(" ").map((e) => Vt(e)).join(" ");
|
|
902
902
|
}
|
|
903
|
-
class
|
|
904
|
-
constructor(
|
|
905
|
-
this.random = (
|
|
903
|
+
class p {
|
|
904
|
+
constructor(t, e) {
|
|
905
|
+
this.random = (u) => this._random(u), this.generate = {
|
|
906
906
|
/**
|
|
907
907
|
* Generates a random word combination using one of three patterns:
|
|
908
908
|
* - adjective noun
|
|
@@ -911,15 +911,15 @@ class O {
|
|
|
911
911
|
* @returns A string with two words following one of the patterns
|
|
912
912
|
*/
|
|
913
913
|
words: () => {
|
|
914
|
-
const
|
|
914
|
+
const u = [
|
|
915
915
|
() => `${this._faker.word.adjective()} ${this._faker.word.noun()}`,
|
|
916
916
|
// adjective noun
|
|
917
917
|
() => `${this._faker.word.adjective()} ${this._faker.word.verb()}`,
|
|
918
918
|
// adjective verb
|
|
919
919
|
() => `${this._faker.word.noun()} ${this._faker.word.verb()}`
|
|
920
920
|
// noun verb
|
|
921
|
-
],
|
|
922
|
-
return
|
|
921
|
+
], c = u[this._faker.number.int({ min: 0, max: u.length - 1 })];
|
|
922
|
+
return c();
|
|
923
923
|
},
|
|
924
924
|
/**
|
|
925
925
|
* Generates a person with firstName, middleName, lastName, and fullName
|
|
@@ -932,153 +932,64 @@ class O {
|
|
|
932
932
|
* @param id - Optional UUID to seed the subfaker. If not provided, generates a new UUID
|
|
933
933
|
* @returns Person object with firstName, middleName, lastName, and fullName
|
|
934
934
|
*/
|
|
935
|
-
person: (
|
|
936
|
-
const
|
|
937
|
-
|
|
938
|
-
const h =
|
|
939
|
-
let
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
const
|
|
935
|
+
person: (u) => {
|
|
936
|
+
const c = u ?? this._faker.string.uuid(), o = new G({ locale: P }), E = B(c);
|
|
937
|
+
o.seed(E);
|
|
938
|
+
const h = o.number.float() < 0.021 ? o.person.lastName() : o.person.firstName();
|
|
939
|
+
let f;
|
|
940
|
+
const _ = o.number.float();
|
|
941
|
+
_ < 307e-5 ? f = `${o.person.firstName()} ${o.person.firstName()}` : _ < 307e-5 + 0.021 ? f = o.person.lastName() : _ < 307e-5 + 0.021 + 0.146 ? f = void 0 : f = o.person.firstName();
|
|
942
|
+
const m = o.number.float() < 0.021 ? `${o.person.lastName()}-${o.person.lastName()}` : o.person.lastName(), g = o.number.float() < 0.146 && f ? `${h} ${f} ${m}` : `${h} ${m}`;
|
|
943
943
|
return {
|
|
944
|
-
id:
|
|
944
|
+
id: c,
|
|
945
945
|
firstName: h,
|
|
946
|
-
middleName:
|
|
947
|
-
lastName:
|
|
948
|
-
fullName:
|
|
946
|
+
middleName: f,
|
|
947
|
+
lastName: m,
|
|
948
|
+
fullName: g
|
|
949
949
|
};
|
|
950
|
-
},
|
|
951
|
-
/**
|
|
952
|
-
* Utility namespace for helper functions
|
|
953
|
-
*/
|
|
954
|
-
util: {
|
|
955
|
-
/**
|
|
956
|
-
* Creates a function that returns predetermined results in sequence,
|
|
957
|
-
* then falls back to generated values
|
|
958
|
-
*
|
|
959
|
-
* @param config - Configuration object
|
|
960
|
-
* @param config.generate - Function to generate values after results are exhausted
|
|
961
|
-
* @param config.results - Array of predetermined results to return in order
|
|
962
|
-
* @param config.seed - Optional seed for the fabricator passed to generate function
|
|
963
|
-
* @returns A function that returns results sequentially, then generates new values
|
|
964
|
-
*
|
|
965
|
-
* @example
|
|
966
|
-
* const getName = fab.generate.util.prefab({
|
|
967
|
-
* results: ["Alice", "Bob"],
|
|
968
|
-
* generate: ({ fabricator }) => fabricator.person.firstName(),
|
|
969
|
-
* });
|
|
970
|
-
* getName(); // "Alice"
|
|
971
|
-
* getName(); // "Bob"
|
|
972
|
-
* getName(); // Generated name
|
|
973
|
-
*/
|
|
974
|
-
prefab: (o) => {
|
|
975
|
-
if (!o.generate || typeof o.generate != "function")
|
|
976
|
-
throw new x("generate must be a function");
|
|
977
|
-
if (!Array.isArray(o.results))
|
|
978
|
-
throw new x("results must be an array");
|
|
979
|
-
const u = o.seed !== void 0 ? new O(o.seed) : this;
|
|
980
|
-
let i = 0;
|
|
981
|
-
return () => i < o.results.length ? o.results[i++] : o.generate({ fabricator: u });
|
|
982
|
-
}
|
|
983
950
|
}
|
|
984
951
|
};
|
|
985
|
-
let
|
|
986
|
-
if (typeof
|
|
987
|
-
const
|
|
988
|
-
this._faker.seed(
|
|
952
|
+
let n, a = {};
|
|
953
|
+
if (typeof t == "object" && t !== null ? (a = t, n = a.seed) : (n = t, e && (a = e)), n === void 0 && process.env.PROJECT_SEED && (n = process.env.PROJECT_SEED), this._faker = new G({ locale: P }), this._random = qt(n), n !== void 0) {
|
|
954
|
+
const u = B(String(n));
|
|
955
|
+
this._faker.seed(u);
|
|
989
956
|
}
|
|
990
|
-
if (
|
|
991
|
-
const
|
|
992
|
-
|
|
957
|
+
if (n !== void 0) {
|
|
958
|
+
const u = String(n);
|
|
959
|
+
J(u) ? this._id = u.toLowerCase() : this._id = Jt(n);
|
|
993
960
|
} else
|
|
994
961
|
this._id = this._faker.string.uuid();
|
|
995
|
-
this.
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
let s;
|
|
1000
|
-
if (Array.isArray(E.name)) {
|
|
1001
|
-
const o = [...E.name];
|
|
1002
|
-
let u = 0;
|
|
1003
|
-
for (; u < o.length; ) {
|
|
1004
|
-
const i = o[u];
|
|
1005
|
-
if (typeof i == "string") {
|
|
1006
|
-
s = i, u + 1 < o.length && (this._remainingNameArray = o.slice(u + 1));
|
|
1007
|
-
break;
|
|
1008
|
-
} else if (typeof i == "function") {
|
|
1009
|
-
const f = new O(this._seedMap.name, {
|
|
1010
|
-
name: ""
|
|
1011
|
-
}), h = i({ fabricator: f });
|
|
1012
|
-
if (h instanceof Promise) {
|
|
1013
|
-
this._name = "", h.then((c) => {
|
|
1014
|
-
if (c)
|
|
1015
|
-
this._name = c;
|
|
1016
|
-
else if (u++, u < o.length) {
|
|
1017
|
-
this._remainingNameArray = o.slice(u);
|
|
1018
|
-
const T = this._generator?.name ?? D;
|
|
1019
|
-
if (typeof T == "function") {
|
|
1020
|
-
const R = T({
|
|
1021
|
-
fabricator: f
|
|
1022
|
-
});
|
|
1023
|
-
R instanceof Promise ? R.then((l) => {
|
|
1024
|
-
this._name = l;
|
|
1025
|
-
}) : this._name = R;
|
|
1026
|
-
} else
|
|
1027
|
-
this._name = T;
|
|
1028
|
-
} else {
|
|
1029
|
-
const T = this._generator?.name ?? D;
|
|
1030
|
-
if (typeof T == "function") {
|
|
1031
|
-
const R = T({
|
|
1032
|
-
fabricator: f
|
|
1033
|
-
});
|
|
1034
|
-
R instanceof Promise ? R.then((l) => {
|
|
1035
|
-
this._name = l;
|
|
1036
|
-
}) : this._name = R;
|
|
1037
|
-
} else
|
|
1038
|
-
this._name = T;
|
|
1039
|
-
}
|
|
1040
|
-
});
|
|
1041
|
-
return;
|
|
1042
|
-
} else if (h) {
|
|
1043
|
-
s = h, u + 1 < o.length && (this._remainingNameArray = o.slice(u + 1));
|
|
1044
|
-
break;
|
|
1045
|
-
} else
|
|
1046
|
-
u++;
|
|
1047
|
-
} else
|
|
1048
|
-
u++;
|
|
1049
|
-
}
|
|
1050
|
-
s || (s = this._generator?.name ?? D);
|
|
1051
|
-
} else
|
|
1052
|
-
s = E.name;
|
|
1053
|
-
if (s === void 0 && (s = this._generator?.name ?? D), typeof s == "function") {
|
|
1054
|
-
const o = new O(this._seedMap.name, {
|
|
962
|
+
this._generator = a.generator;
|
|
963
|
+
const i = a.name === void 0 ? this._generator?.name ?? x : a.name;
|
|
964
|
+
if (typeof i == "function") {
|
|
965
|
+
const u = U("name", this._id), c = new p(u, {
|
|
1055
966
|
name: ""
|
|
1056
|
-
}),
|
|
1057
|
-
if (
|
|
1058
|
-
this._name = "",
|
|
1059
|
-
if ((
|
|
1060
|
-
const
|
|
1061
|
-
if (typeof
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
this._name =
|
|
1065
|
-
}) : this._name =
|
|
967
|
+
}), o = i({ fabricator: c });
|
|
968
|
+
if (o instanceof Promise)
|
|
969
|
+
this._name = "", o.then((E) => {
|
|
970
|
+
if ((E === void 0 || E === "") && this._generator?.name) {
|
|
971
|
+
const h = this._generator.name;
|
|
972
|
+
if (typeof h == "function") {
|
|
973
|
+
const f = h({ fabricator: c });
|
|
974
|
+
f instanceof Promise ? f.then((_) => {
|
|
975
|
+
this._name = _;
|
|
976
|
+
}) : this._name = f;
|
|
1066
977
|
} else
|
|
1067
|
-
this._name =
|
|
1068
|
-
} else
|
|
978
|
+
this._name = h;
|
|
979
|
+
} else E === void 0 || E === "" ? this._name = x({ fabricator: c }) : this._name = E;
|
|
1069
980
|
});
|
|
1070
|
-
else if ((
|
|
1071
|
-
const
|
|
1072
|
-
if (typeof
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
this._name =
|
|
1076
|
-
})) : this._name =
|
|
981
|
+
else if ((o === void 0 || o === "") && this._generator?.name) {
|
|
982
|
+
const E = this._generator.name;
|
|
983
|
+
if (typeof E == "function") {
|
|
984
|
+
const h = E({ fabricator: c });
|
|
985
|
+
h instanceof Promise ? (this._name = "", h.then((f) => {
|
|
986
|
+
this._name = f;
|
|
987
|
+
})) : this._name = h;
|
|
1077
988
|
} else
|
|
1078
|
-
this._name =
|
|
1079
|
-
} else
|
|
989
|
+
this._name = E;
|
|
990
|
+
} else o === void 0 || o === "" ? this._name = x({ fabricator: c }) : this._name = o;
|
|
1080
991
|
} else
|
|
1081
|
-
this._name =
|
|
992
|
+
this._name = i;
|
|
1082
993
|
}
|
|
1083
994
|
/**
|
|
1084
995
|
* Creates a new nested fabricator from a configuration object
|
|
@@ -1108,41 +1019,41 @@ class O {
|
|
|
1108
1019
|
* const city = world.cities(1)[0];
|
|
1109
1020
|
* city.streets(10); // Returns array of 10 street fabricators
|
|
1110
1021
|
*/
|
|
1111
|
-
static new(
|
|
1112
|
-
const
|
|
1113
|
-
generator:
|
|
1114
|
-
name:
|
|
1115
|
-
seed:
|
|
1022
|
+
static new(t) {
|
|
1023
|
+
const e = new p({
|
|
1024
|
+
generator: t.generator,
|
|
1025
|
+
name: t.name,
|
|
1026
|
+
seed: t.seed
|
|
1116
1027
|
});
|
|
1117
|
-
if (t.
|
|
1118
|
-
return
|
|
1119
|
-
const
|
|
1120
|
-
for (const [
|
|
1121
|
-
const
|
|
1122
|
-
if (
|
|
1123
|
-
const
|
|
1028
|
+
if (!t.fabricators)
|
|
1029
|
+
return e;
|
|
1030
|
+
const n = e;
|
|
1031
|
+
for (const [a, i] of Object.entries(t.fabricators)) {
|
|
1032
|
+
const u = (c) => {
|
|
1033
|
+
if (c === void 0) {
|
|
1034
|
+
const E = e.id;
|
|
1124
1035
|
return (function* () {
|
|
1125
1036
|
let h = 0;
|
|
1126
1037
|
for (; ; )
|
|
1127
|
-
yield
|
|
1128
|
-
...
|
|
1129
|
-
seed: `${
|
|
1038
|
+
yield p.new({
|
|
1039
|
+
...i,
|
|
1040
|
+
seed: `${E}-${a}-${h++}`
|
|
1130
1041
|
});
|
|
1131
1042
|
})();
|
|
1132
1043
|
}
|
|
1133
|
-
const
|
|
1134
|
-
for (let
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
...
|
|
1138
|
-
seed: `${
|
|
1044
|
+
const o = [];
|
|
1045
|
+
for (let E = 0; E < c; E++)
|
|
1046
|
+
o.push(
|
|
1047
|
+
p.new({
|
|
1048
|
+
...i,
|
|
1049
|
+
seed: `${e.id}-${a}-${E}`
|
|
1139
1050
|
})
|
|
1140
1051
|
);
|
|
1141
|
-
return
|
|
1052
|
+
return o;
|
|
1142
1053
|
};
|
|
1143
|
-
|
|
1054
|
+
n[a] = u;
|
|
1144
1055
|
}
|
|
1145
|
-
return
|
|
1056
|
+
return n;
|
|
1146
1057
|
}
|
|
1147
1058
|
/**
|
|
1148
1059
|
* Gets the internal faker instance
|
|
@@ -1162,21 +1073,6 @@ class O {
|
|
|
1162
1073
|
get name() {
|
|
1163
1074
|
return this._name;
|
|
1164
1075
|
}
|
|
1165
|
-
/**
|
|
1166
|
-
* Creates a new Fabricator instance with next seed from _seedMap
|
|
1167
|
-
* @returns A new Fabricator instance seeded with the next UUID, chaining the name option and nested config if present
|
|
1168
|
-
*/
|
|
1169
|
-
next() {
|
|
1170
|
-
if (this._nestedConfig)
|
|
1171
|
-
return O.new({
|
|
1172
|
-
...this._nestedConfig,
|
|
1173
|
-
seed: this._seedMap.next
|
|
1174
|
-
});
|
|
1175
|
-
const e = {
|
|
1176
|
-
seed: this._seedMap.next
|
|
1177
|
-
};
|
|
1178
|
-
return this._generator !== void 0 && (e.generator = this._generator), this._remainingNameArray && this._remainingNameArray.length > 0 ? e.name = this._remainingNameArray : this._nameOption !== void 0 && (e.name = this._nameOption), new O(e);
|
|
1179
|
-
}
|
|
1180
1076
|
// Proxy all faker fields for direct access
|
|
1181
1077
|
get airline() {
|
|
1182
1078
|
return this._faker.airline;
|
|
@@ -1254,21 +1150,21 @@ class O {
|
|
|
1254
1150
|
return this._faker.word;
|
|
1255
1151
|
}
|
|
1256
1152
|
}
|
|
1257
|
-
function
|
|
1258
|
-
return typeof
|
|
1153
|
+
function Kt(r, t) {
|
|
1154
|
+
return typeof r == "object" && r !== null ? new p(r) : t ? new p(r, t) : r !== void 0 ? new p(r) : new p();
|
|
1259
1155
|
}
|
|
1260
1156
|
export {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1157
|
+
zt as CHANCE,
|
|
1158
|
+
kt as DEFAULT_MAX,
|
|
1159
|
+
Ft as DEFAULT_MIN,
|
|
1160
|
+
p as Fabricator,
|
|
1161
|
+
Qt as JAYPIE_FABRICATOR_UUID,
|
|
1162
|
+
Kt as fabricator,
|
|
1163
|
+
J as isUuid,
|
|
1164
|
+
v as numericSeed,
|
|
1165
|
+
B as numericSeedArray,
|
|
1166
|
+
qt as random,
|
|
1167
|
+
Jt as uuidFrom,
|
|
1168
|
+
at as uuidToBytes,
|
|
1169
|
+
H as uuidToNumber
|
|
1274
1170
|
};
|