tyneq 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -1
- package/dist/{TyneqCachedTerminalOperator.d.ts → TyneqCachedTerminalOperator-BrW77zIy.d.ts} +328 -173
- package/dist/{TyneqCachedTerminalOperator.d.cts → TyneqCachedTerminalOperator-EaNiNt61.d.cts} +328 -173
- package/dist/chunk-5R4AALC7.js +680 -0
- package/dist/chunk-C5PBY3ZU.cjs +46 -0
- package/dist/chunk-OWKUE3AC.cjs +680 -0
- package/dist/chunk-PCBN5AFG.js +46 -0
- package/dist/chunk-VJAICXA6.cjs +3788 -0
- package/dist/chunk-ZP6WMZCK.js +3788 -0
- package/dist/core-C54TSmgW.d.cts +1390 -0
- package/dist/core-C54TSmgW.d.ts +1390 -0
- package/dist/index.cjs +638 -843
- package/dist/index.d.cts +405 -605
- package/dist/index.d.ts +405 -605
- package/dist/index.js +630 -781
- package/dist/plugin/index.cjs +51 -24
- package/dist/plugin/index.d.cts +35 -38
- package/dist/plugin/index.d.ts +35 -38
- package/dist/plugin/index.js +51 -2
- package/dist/utility/index.cjs +18 -9
- package/dist/utility/index.d.cts +312 -2
- package/dist/utility/index.d.ts +312 -2
- package/dist/utility/index.js +18 -3
- package/package.json +5 -5
- package/dist/Lazy.cjs +0 -762
- package/dist/Lazy.cjs.map +0 -1
- package/dist/Lazy.js +0 -691
- package/dist/Lazy.js.map +0 -1
- package/dist/TyneqCachedTerminalOperator.cjs +0 -4950
- package/dist/TyneqCachedTerminalOperator.cjs.map +0 -1
- package/dist/TyneqCachedTerminalOperator.d.cts.map +0 -1
- package/dist/TyneqCachedTerminalOperator.d.ts.map +0 -1
- package/dist/TyneqCachedTerminalOperator.js +0 -4741
- package/dist/TyneqCachedTerminalOperator.js.map +0 -1
- package/dist/ValidationBuilder.cjs +0 -80
- package/dist/ValidationBuilder.cjs.map +0 -1
- package/dist/ValidationBuilder.d.cts +0 -319
- package/dist/ValidationBuilder.d.cts.map +0 -1
- package/dist/ValidationBuilder.d.ts +0 -319
- package/dist/ValidationBuilder.d.ts.map +0 -1
- package/dist/ValidationBuilder.js +0 -69
- package/dist/ValidationBuilder.js.map +0 -1
- package/dist/core.d.cts +0 -1393
- package/dist/core.d.cts.map +0 -1
- package/dist/core.d.ts +0 -1393
- package/dist/core.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugin/index.d.cts.map +0 -1
- package/dist/plugin/index.d.ts.map +0 -1
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
|
+
};
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __decoratorStart = (base) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return [, , , __create((_a = base == null ? void 0 : base[__knownSymbol("metadata")]) != null ? _a : null)];
|
|
13
|
+
};
|
|
14
|
+
var __decoratorStrings = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"];
|
|
15
|
+
var __expectFn = (fn) => fn !== void 0 && typeof fn !== "function" ? __typeError("Function expected") : fn;
|
|
16
|
+
var __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError("Already initialized") : fns.push(__expectFn(fn || null)) });
|
|
17
|
+
var __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol("metadata"), array[3]);
|
|
18
|
+
var __runInitializers = (array, flags, self, value) => {
|
|
19
|
+
for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);
|
|
20
|
+
return value;
|
|
21
|
+
};
|
|
22
|
+
var __decorateElement = (array, flags, name, decorators, target, extra) => {
|
|
23
|
+
var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);
|
|
24
|
+
var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];
|
|
25
|
+
var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);
|
|
26
|
+
var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {
|
|
27
|
+
return __privateGet(this, extra);
|
|
28
|
+
}, set [name](x) {
|
|
29
|
+
return __privateSet(this, extra, x);
|
|
30
|
+
} }, name));
|
|
31
|
+
k ? p && k < 4 && __name(extra, (k > 2 ? "set " : k > 1 ? "get " : "") + name) : __name(target, name);
|
|
32
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
33
|
+
ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);
|
|
34
|
+
if (k) {
|
|
35
|
+
ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };
|
|
36
|
+
if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];
|
|
37
|
+
if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;
|
|
38
|
+
}
|
|
39
|
+
it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;
|
|
40
|
+
if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);
|
|
41
|
+
else if (typeof it !== "object" || it === null) __typeError("Object expected");
|
|
42
|
+
else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);
|
|
43
|
+
}
|
|
44
|
+
return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
|
|
45
|
+
};
|
|
46
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
47
|
+
var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
|
|
48
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
49
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
50
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
51
|
+
var __await = function(promise, isYieldStar) {
|
|
52
|
+
this[0] = promise;
|
|
53
|
+
this[1] = isYieldStar;
|
|
54
|
+
};
|
|
55
|
+
var __asyncGenerator = (__this, __arguments, generator) => {
|
|
56
|
+
var resume = (k, v, yes, no) => {
|
|
57
|
+
try {
|
|
58
|
+
var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
|
|
59
|
+
Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
no(e);
|
|
62
|
+
}
|
|
63
|
+
}, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
|
|
64
|
+
return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// src/core/errors/TyneqError.ts
|
|
68
|
+
var TyneqError = class extends Error {
|
|
69
|
+
constructor(message, options) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.name = new.target.name;
|
|
72
|
+
this.inner = options == null ? void 0 : options.inner;
|
|
73
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/core/errors/argument/ArgumentError.ts
|
|
78
|
+
var ArgumentError = class extends TyneqError {
|
|
79
|
+
constructor(message, paramName, inner) {
|
|
80
|
+
super(message, { inner });
|
|
81
|
+
this.paramName = paramName;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/core/errors/argument/ArgumentNullError.ts
|
|
86
|
+
var ArgumentNullError = class extends ArgumentError {
|
|
87
|
+
constructor(paramName, inner) {
|
|
88
|
+
super(`${paramName} cannot be null.`, paramName, inner);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/core/errors/argument/ArgumentOutOfRangeError.ts
|
|
93
|
+
var ArgumentOutOfRangeError = class extends ArgumentError {
|
|
94
|
+
constructor(paramName, message, actualValue, inner) {
|
|
95
|
+
super(message != null ? message : `${paramName} was out of range.`, paramName, inner);
|
|
96
|
+
this.actualValue = actualValue;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// src/core/errors/argument/ArgumentTypeError.ts
|
|
101
|
+
var ArgumentTypeError = class extends ArgumentError {
|
|
102
|
+
constructor(paramName, expectedType, actualType, message, inner) {
|
|
103
|
+
let errorMessage;
|
|
104
|
+
if (message) {
|
|
105
|
+
errorMessage = message;
|
|
106
|
+
} else if (expectedType && actualType) {
|
|
107
|
+
errorMessage = `'${paramName}' expected type ${expectedType} but got ${actualType}.`;
|
|
108
|
+
} else if (expectedType) {
|
|
109
|
+
errorMessage = `'${paramName}' must be of type ${expectedType}.`;
|
|
110
|
+
} else {
|
|
111
|
+
errorMessage = `'${paramName}' has incorrect type.`;
|
|
112
|
+
}
|
|
113
|
+
super(errorMessage, paramName, inner);
|
|
114
|
+
this.expectedType = expectedType;
|
|
115
|
+
this.actualType = actualType;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/utility/TypeGuardUtility.ts
|
|
120
|
+
var TypeGuardUtility = class {
|
|
121
|
+
constructor() {
|
|
122
|
+
}
|
|
123
|
+
static isIterable(value) {
|
|
124
|
+
return value !== null && value !== void 0 && typeof value[Symbol.iterator] === "function";
|
|
125
|
+
}
|
|
126
|
+
static isIterator(value) {
|
|
127
|
+
const valueType = typeof value;
|
|
128
|
+
return value !== null && (valueType === "object" || valueType === "function") && typeof value.next === "function";
|
|
129
|
+
}
|
|
130
|
+
static isIterableIterator(value) {
|
|
131
|
+
return this.isIterable(value) && this.isIterator(value);
|
|
132
|
+
}
|
|
133
|
+
static isEnumerator(value) {
|
|
134
|
+
if (!this.isIterator(value)) return false;
|
|
135
|
+
const candidate = value;
|
|
136
|
+
return (candidate.return === void 0 || typeof candidate.return === "function") && (candidate.throw === void 0 || typeof candidate.throw === "function");
|
|
137
|
+
}
|
|
138
|
+
static isEnumerable(value) {
|
|
139
|
+
if (value === null || value === void 0) return false;
|
|
140
|
+
const candidate = value;
|
|
141
|
+
return this.isIterable(value) && typeof candidate.getEnumerator === "function";
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// src/utility/nameof.ts
|
|
146
|
+
function nameof(param) {
|
|
147
|
+
if (param === null || typeof param !== "object") {
|
|
148
|
+
throw new TypeError("nameof expects a non-null object with exactly one own enumerable property.");
|
|
149
|
+
}
|
|
150
|
+
const keys = Object.keys(param);
|
|
151
|
+
if (keys.length !== 1) {
|
|
152
|
+
throw new TypeError("nameof expects an object with exactly one own enumerable property.");
|
|
153
|
+
}
|
|
154
|
+
const key = keys[0];
|
|
155
|
+
return [key, param[key]];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// src/utility/guards/extractParameter.ts
|
|
159
|
+
function extractParameter(param, paramName) {
|
|
160
|
+
const [extractedParamName, value] = paramName ? [paramName, param] : nameof(param);
|
|
161
|
+
return { key: extractedParamName, value };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/utility/guards/NullGuards.ts
|
|
165
|
+
var NullGuards = class _NullGuards {
|
|
166
|
+
constructor() {
|
|
167
|
+
}
|
|
168
|
+
static checkNotNull(value, paramName) {
|
|
169
|
+
if (value === null) {
|
|
170
|
+
throw new ArgumentNullError(paramName);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
static checkNotUndefined(value, paramName) {
|
|
174
|
+
if (value === void 0) {
|
|
175
|
+
throw new ArgumentError(`'${paramName}' cannot be undefined.`, paramName);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
static checkNotOptional(value, paramName) {
|
|
179
|
+
_NullGuards.checkNotNull(value, paramName);
|
|
180
|
+
_NullGuards.checkNotUndefined(value, paramName);
|
|
181
|
+
}
|
|
182
|
+
static checkNotNullOrEmpty(value, paramName) {
|
|
183
|
+
_NullGuards.checkNotNull(value, paramName);
|
|
184
|
+
if (value.length === 0) {
|
|
185
|
+
throw new ArgumentError(`'${paramName}' cannot be empty.`, paramName);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
static checkNotOptionalOrEmpty(value, paramName) {
|
|
189
|
+
_NullGuards.checkNotOptional(value, paramName);
|
|
190
|
+
if (value.length === 0) {
|
|
191
|
+
throw new ArgumentError(`'${paramName}' cannot be empty.`, paramName);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/utility/guards/StringGuards.ts
|
|
197
|
+
var StringGuards = class {
|
|
198
|
+
constructor() {
|
|
199
|
+
}
|
|
200
|
+
static checkNotNullOrWhiteSpace(value, paramName) {
|
|
201
|
+
NullGuards.checkNotOptional(value, paramName);
|
|
202
|
+
if (value.trim().length === 0) {
|
|
203
|
+
throw new ArgumentError(`'${paramName}' cannot be empty or whitespace.`, paramName);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
// src/utility/guards/NumericGuards.ts
|
|
209
|
+
var NumericGuards = class _NumericGuards {
|
|
210
|
+
constructor() {
|
|
211
|
+
}
|
|
212
|
+
static checkNonNegative(value, paramName) {
|
|
213
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
214
|
+
throw new ArgumentOutOfRangeError(paramName, `'${paramName}' must be a non-negative number.`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
static checkPositive(value, paramName) {
|
|
218
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
219
|
+
throw new ArgumentOutOfRangeError(paramName, `'${paramName}' must be a positive number.`);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
static checkNegative(value, paramName) {
|
|
223
|
+
if (!Number.isFinite(value) || value >= 0) {
|
|
224
|
+
throw new ArgumentOutOfRangeError(paramName, `'${paramName}' must be a negative number.`, value);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
static checkNonPositive(value, paramName) {
|
|
228
|
+
if (!Number.isFinite(value) || value > 0) {
|
|
229
|
+
throw new ArgumentOutOfRangeError(paramName, `'${paramName}' must be a non-positive number.`, value);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
static checkInRange(value, min, max, paramName) {
|
|
233
|
+
if (min > max) {
|
|
234
|
+
throw new ArgumentError(`'min' (${min}) must be <= 'max' (${max}).`, "min");
|
|
235
|
+
}
|
|
236
|
+
if (!Number.isFinite(value) || value < min || value > max) {
|
|
237
|
+
throw new ArgumentOutOfRangeError(paramName, `'${paramName}' must be in range [${min}, ${max}].`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
static checkInteger(value, paramName) {
|
|
241
|
+
if (!Number.isFinite(value) || !Number.isInteger(value)) {
|
|
242
|
+
throw new ArgumentError(`'${paramName}' must be an integer.`, paramName);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
static checkFinite(value, paramName) {
|
|
246
|
+
if (!Number.isFinite(value)) {
|
|
247
|
+
throw new ArgumentError(`'${paramName}' must be a finite number.`, paramName);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
static checkNotNaN(value, paramName) {
|
|
251
|
+
if (Number.isNaN(value)) {
|
|
252
|
+
throw new ArgumentError(`'${paramName}' cannot be NaN.`, paramName);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
static checkSafeInteger(value, paramName) {
|
|
256
|
+
if (!Number.isSafeInteger(value)) {
|
|
257
|
+
throw new ArgumentError(`'${paramName}' must be a safe integer.`, paramName);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
static checkArrayIndex(value, paramName, arrayLength) {
|
|
261
|
+
_NumericGuards.checkSafeInteger(value, paramName);
|
|
262
|
+
const maxLength = arrayLength != null ? arrayLength : Number.MAX_SAFE_INTEGER;
|
|
263
|
+
if (value < 0 || value >= maxLength) {
|
|
264
|
+
throw new ArgumentOutOfRangeError(
|
|
265
|
+
paramName,
|
|
266
|
+
`'${paramName}' must be in range [0, ${maxLength}).`,
|
|
267
|
+
value
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/utility/guards/TypeGuards.ts
|
|
274
|
+
var TypeGuards = class {
|
|
275
|
+
constructor() {
|
|
276
|
+
}
|
|
277
|
+
static checkFunction(value, paramName) {
|
|
278
|
+
if (typeof value !== "function") {
|
|
279
|
+
throw new ArgumentTypeError(paramName, "function", typeof value);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
static checkIterable(value, paramName) {
|
|
283
|
+
if (!TypeGuardUtility.isIterable(value)) {
|
|
284
|
+
const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
|
|
285
|
+
throw new ArgumentTypeError(paramName, "iterable", actualType);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
static checkIterator(value, paramName) {
|
|
289
|
+
if (!TypeGuardUtility.isIterator(value)) {
|
|
290
|
+
const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
|
|
291
|
+
throw new ArgumentTypeError(paramName, "iterator", actualType);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
static checkEnumerable(value, paramName) {
|
|
295
|
+
if (!TypeGuardUtility.isEnumerable(value)) {
|
|
296
|
+
const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
|
|
297
|
+
throw new ArgumentTypeError(paramName, "Enumerable", actualType);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
static checkEnumerator(value, paramName) {
|
|
301
|
+
if (!TypeGuardUtility.isEnumerator(value)) {
|
|
302
|
+
const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
|
|
303
|
+
throw new ArgumentTypeError(paramName, "Enumerator", actualType);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
static checkInstanceOf(value, constructor, paramName) {
|
|
307
|
+
if (!(value instanceof constructor)) {
|
|
308
|
+
const constructorName = constructor.name || "unknown";
|
|
309
|
+
const actualType = value === null ? "null" : value === void 0 ? "undefined" : typeof value;
|
|
310
|
+
throw new ArgumentTypeError(paramName, constructorName, actualType);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
static checkHasLength(value, paramName) {
|
|
314
|
+
if (typeof value !== "object" || value === null || typeof value.length !== "number") {
|
|
315
|
+
throw new ArgumentTypeError(paramName, "object with numeric length property", typeof value);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
static check(value, paramName, predicate, message) {
|
|
319
|
+
if (!predicate(value)) {
|
|
320
|
+
throw new ArgumentError(message, paramName);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/utility/ArgumentUtility.ts
|
|
326
|
+
var ArgumentUtility = class {
|
|
327
|
+
constructor() {
|
|
328
|
+
}
|
|
329
|
+
static checkNotNull(param, paramName) {
|
|
330
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
331
|
+
NullGuards.checkNotNull(value, key);
|
|
332
|
+
}
|
|
333
|
+
static checkNotUndefined(param, paramName) {
|
|
334
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
335
|
+
NullGuards.checkNotUndefined(value, key);
|
|
336
|
+
}
|
|
337
|
+
static checkNotOptional(param, paramName) {
|
|
338
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
339
|
+
NullGuards.checkNotOptional(value, key);
|
|
340
|
+
}
|
|
341
|
+
static checkNotNullOrEmpty(param, paramName) {
|
|
342
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
343
|
+
NullGuards.checkNotNullOrEmpty(value, key);
|
|
344
|
+
}
|
|
345
|
+
static checkNotOptionalOrEmpty(param, paramName) {
|
|
346
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
347
|
+
NullGuards.checkNotOptionalOrEmpty(value, key);
|
|
348
|
+
}
|
|
349
|
+
static checkNotNullOrWhiteSpace(param, paramName) {
|
|
350
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
351
|
+
StringGuards.checkNotNullOrWhiteSpace(value, key);
|
|
352
|
+
}
|
|
353
|
+
static checkNonNegative(param, paramName) {
|
|
354
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
355
|
+
NumericGuards.checkNonNegative(value, key);
|
|
356
|
+
}
|
|
357
|
+
static checkPositive(param, paramName) {
|
|
358
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
359
|
+
NumericGuards.checkPositive(value, key);
|
|
360
|
+
}
|
|
361
|
+
static checkNegative(param, paramName) {
|
|
362
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
363
|
+
NumericGuards.checkNegative(value, key);
|
|
364
|
+
}
|
|
365
|
+
static checkNonPositive(param, paramName) {
|
|
366
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
367
|
+
NumericGuards.checkNonPositive(value, key);
|
|
368
|
+
}
|
|
369
|
+
static checkInRange(param, min, max, paramName) {
|
|
370
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
371
|
+
NumericGuards.checkInRange(value, min, max, key);
|
|
372
|
+
}
|
|
373
|
+
static checkInteger(param, paramName) {
|
|
374
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
375
|
+
NumericGuards.checkInteger(value, key);
|
|
376
|
+
}
|
|
377
|
+
static checkFinite(param, paramName) {
|
|
378
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
379
|
+
NumericGuards.checkFinite(value, key);
|
|
380
|
+
}
|
|
381
|
+
static checkNotNaN(param, paramName) {
|
|
382
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
383
|
+
NumericGuards.checkNotNaN(value, key);
|
|
384
|
+
}
|
|
385
|
+
static checkSafeInteger(param, paramName) {
|
|
386
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
387
|
+
NumericGuards.checkSafeInteger(value, key);
|
|
388
|
+
}
|
|
389
|
+
static checkArrayIndex(param, paramNameOrArrayLength, arrayLength) {
|
|
390
|
+
const hasExplicitParamName = typeof paramNameOrArrayLength === "string";
|
|
391
|
+
const { key, value } = hasExplicitParamName ? this.extractParameter(param, paramNameOrArrayLength) : this.extractParameter(param);
|
|
392
|
+
const resolvedArrayLength = hasExplicitParamName ? arrayLength : paramNameOrArrayLength;
|
|
393
|
+
NumericGuards.checkArrayIndex(value, key, resolvedArrayLength);
|
|
394
|
+
}
|
|
395
|
+
static checkFunction(param, paramName) {
|
|
396
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
397
|
+
TypeGuards.checkFunction(value, key);
|
|
398
|
+
}
|
|
399
|
+
static checkIterable(param, paramName) {
|
|
400
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
401
|
+
TypeGuards.checkIterable(value, key);
|
|
402
|
+
}
|
|
403
|
+
static checkIterator(param, paramName) {
|
|
404
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
405
|
+
TypeGuards.checkIterator(value, key);
|
|
406
|
+
}
|
|
407
|
+
static checkEnumerable(param, paramName) {
|
|
408
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
409
|
+
TypeGuards.checkEnumerable(value, key);
|
|
410
|
+
}
|
|
411
|
+
static checkEnumerator(param, paramName) {
|
|
412
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
413
|
+
TypeGuards.checkEnumerator(value, key);
|
|
414
|
+
}
|
|
415
|
+
static checkInstanceOf(param, constructor, paramName) {
|
|
416
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
417
|
+
TypeGuards.checkInstanceOf(value, constructor, key);
|
|
418
|
+
}
|
|
419
|
+
static checkHasLength(param, paramName) {
|
|
420
|
+
const { key, value } = this.extractParameter(param, paramName);
|
|
421
|
+
TypeGuards.checkHasLength(value, key);
|
|
422
|
+
}
|
|
423
|
+
static check(param, paramNameOrPredicate, predicateOrMessage, message) {
|
|
424
|
+
const hasExplicitParamName = typeof paramNameOrPredicate === "string";
|
|
425
|
+
const predicate = hasExplicitParamName ? predicateOrMessage : paramNameOrPredicate;
|
|
426
|
+
const validationMessage = hasExplicitParamName ? message : predicateOrMessage;
|
|
427
|
+
const { key, value } = hasExplicitParamName ? this.extractParameter(param, paramNameOrPredicate) : this.extractParameter(param);
|
|
428
|
+
TypeGuards.check(value, key, predicate, validationMessage);
|
|
429
|
+
}
|
|
430
|
+
static extractParameter(param, paramName) {
|
|
431
|
+
return extractParameter(param, paramName);
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// src/core/errors/ReflectionError.ts
|
|
436
|
+
var ReflectionError = class extends TyneqError {
|
|
437
|
+
constructor(message, methodName, prototypeName, inner) {
|
|
438
|
+
super(message, { inner });
|
|
439
|
+
this.methodName = methodName;
|
|
440
|
+
this.prototypeName = prototypeName;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
// src/utility/reflect.ts
|
|
445
|
+
var ReflectionContext = class {
|
|
446
|
+
/** @internal */
|
|
447
|
+
constructor(proto, options) {
|
|
448
|
+
this.proto = proto;
|
|
449
|
+
this.options = options;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Returns descriptors for all own (and optionally inherited) members,
|
|
453
|
+
* excluding `constructor`.
|
|
454
|
+
*/
|
|
455
|
+
members() {
|
|
456
|
+
return this.collectDescriptors(this.proto);
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Returns descriptors for all method members (function-valued own properties),
|
|
460
|
+
* excluding `constructor`.
|
|
461
|
+
*/
|
|
462
|
+
methods() {
|
|
463
|
+
return this.members().filter((d) => d.kind === "method");
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Returns descriptors for all data members (non-function value properties).
|
|
467
|
+
*/
|
|
468
|
+
fields() {
|
|
469
|
+
return this.members().filter((d) => d.kind === "data");
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Returns descriptors for all accessor members (get/set properties).
|
|
473
|
+
*/
|
|
474
|
+
accessors() {
|
|
475
|
+
return this.members().filter((d) => d.kind === "accessor");
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Returns the descriptor for the named member, or `undefined` if not found.
|
|
479
|
+
*/
|
|
480
|
+
get(name) {
|
|
481
|
+
return this.findDescriptor(name);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Returns `true` if a member with the given name exists on the target.
|
|
485
|
+
*/
|
|
486
|
+
has(name) {
|
|
487
|
+
return this.findDescriptor(name) !== void 0;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Returns the method descriptor for `name`, or throws {@link ReflectionError}
|
|
491
|
+
* if the member does not exist or is not a method.
|
|
492
|
+
*
|
|
493
|
+
* @throws {ReflectionError} when the member is absent or is not a method.
|
|
494
|
+
*/
|
|
495
|
+
getMethod(name) {
|
|
496
|
+
var _a, _b, _c, _d, _e, _f;
|
|
497
|
+
const descriptor = this.findDescriptor(name);
|
|
498
|
+
if (descriptor === void 0) {
|
|
499
|
+
const prototypeName = (_c = (_b = (_a = this.proto) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name) != null ? _c : "unknown";
|
|
500
|
+
throw new ReflectionError(
|
|
501
|
+
`Method "${String(name)}" not found on ${prototypeName}. Ensure the method is defined directly on the class, not inherited or deleted.`,
|
|
502
|
+
String(name),
|
|
503
|
+
prototypeName
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
if (descriptor.kind !== "method") {
|
|
507
|
+
const prototypeName = (_f = (_e = (_d = this.proto) == null ? void 0 : _d.constructor) == null ? void 0 : _e.name) != null ? _f : "unknown";
|
|
508
|
+
throw new ReflectionError(
|
|
509
|
+
`Member "${String(name)}" on ${prototypeName} is a ${descriptor.kind}, not a method.`,
|
|
510
|
+
String(name),
|
|
511
|
+
prototypeName
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
return descriptor;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Returns the accessor descriptor for `name`, or throws {@link ReflectionError}
|
|
518
|
+
* if the member does not exist or is not an accessor.
|
|
519
|
+
*
|
|
520
|
+
* @throws {ReflectionError} when the member is absent or is not an accessor.
|
|
521
|
+
*/
|
|
522
|
+
getAccessor(name) {
|
|
523
|
+
var _a, _b, _c, _d, _e, _f;
|
|
524
|
+
const descriptor = this.findDescriptor(name);
|
|
525
|
+
if (descriptor === void 0) {
|
|
526
|
+
const prototypeName = (_c = (_b = (_a = this.proto) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name) != null ? _c : "unknown";
|
|
527
|
+
throw new ReflectionError(
|
|
528
|
+
`Accessor "${String(name)}" not found on ${prototypeName}.`,
|
|
529
|
+
String(name),
|
|
530
|
+
prototypeName
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
if (descriptor.kind !== "accessor") {
|
|
534
|
+
const prototypeName = (_f = (_e = (_d = this.proto) == null ? void 0 : _d.constructor) == null ? void 0 : _e.name) != null ? _f : "unknown";
|
|
535
|
+
throw new ReflectionError(
|
|
536
|
+
`Member "${String(name)}" on ${prototypeName} is a ${descriptor.kind}, not an accessor.`,
|
|
537
|
+
String(name),
|
|
538
|
+
prototypeName
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
return descriptor;
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* Returns `true` if a method with the given name exists on the target.
|
|
545
|
+
*
|
|
546
|
+
* Unlike {@link has}, this returns `false` if the member exists but is an accessor or data property.
|
|
547
|
+
*/
|
|
548
|
+
hasMethod(name) {
|
|
549
|
+
var _a;
|
|
550
|
+
return ((_a = this.findDescriptor(name)) == null ? void 0 : _a.kind) === "method";
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Returns the method descriptor for `name`, or `undefined` if the member does not
|
|
554
|
+
* exist or is not a method. Never throws.
|
|
555
|
+
*/
|
|
556
|
+
tryGetMethod(name) {
|
|
557
|
+
const descriptor = this.findDescriptor(name);
|
|
558
|
+
return (descriptor == null ? void 0 : descriptor.kind) === "method" ? descriptor : void 0;
|
|
559
|
+
}
|
|
560
|
+
findDescriptor(name) {
|
|
561
|
+
let current = this.proto;
|
|
562
|
+
const stop = Object.prototype;
|
|
563
|
+
while (current !== null && current !== stop) {
|
|
564
|
+
const raw = Object.getOwnPropertyDescriptor(current, name);
|
|
565
|
+
if (raw !== void 0) {
|
|
566
|
+
return buildDescriptor(name, raw);
|
|
567
|
+
}
|
|
568
|
+
if (!this.options.inherited) break;
|
|
569
|
+
current = Object.getPrototypeOf(current);
|
|
570
|
+
}
|
|
571
|
+
return void 0;
|
|
572
|
+
}
|
|
573
|
+
collectDescriptors(startProto) {
|
|
574
|
+
const seen = /* @__PURE__ */ new Set();
|
|
575
|
+
const results = [];
|
|
576
|
+
const stop = Object.prototype;
|
|
577
|
+
let current = startProto;
|
|
578
|
+
while (current !== null && current !== stop) {
|
|
579
|
+
const keys = this.options.symbols ? Reflect.ownKeys(current) : Object.getOwnPropertyNames(current);
|
|
580
|
+
for (const key of keys) {
|
|
581
|
+
if (key === "constructor") continue;
|
|
582
|
+
if (seen.has(key)) continue;
|
|
583
|
+
seen.add(key);
|
|
584
|
+
const raw = Object.getOwnPropertyDescriptor(current, key);
|
|
585
|
+
if (raw === void 0) continue;
|
|
586
|
+
const descriptor = buildDescriptor(key, raw);
|
|
587
|
+
if (descriptor !== void 0) {
|
|
588
|
+
results.push(descriptor);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
if (!this.options.inherited) break;
|
|
592
|
+
current = Object.getPrototypeOf(current);
|
|
593
|
+
}
|
|
594
|
+
return results;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
function reflect(target, options = {}) {
|
|
598
|
+
const proto = resolveProto(target);
|
|
599
|
+
return new ReflectionContext(proto, options);
|
|
600
|
+
}
|
|
601
|
+
function resolveProto(target) {
|
|
602
|
+
if (typeof target === "function") {
|
|
603
|
+
return target.prototype;
|
|
604
|
+
}
|
|
605
|
+
return target;
|
|
606
|
+
}
|
|
607
|
+
function buildDescriptor(name, raw) {
|
|
608
|
+
var _a, _b, _c, _d, _e;
|
|
609
|
+
if ("get" in raw || "set" in raw) {
|
|
610
|
+
return {
|
|
611
|
+
kind: "accessor",
|
|
612
|
+
name,
|
|
613
|
+
get: raw.get,
|
|
614
|
+
set: raw.set,
|
|
615
|
+
configurable: (_a = raw.configurable) != null ? _a : false,
|
|
616
|
+
enumerable: (_b = raw.enumerable) != null ? _b : false,
|
|
617
|
+
canRead: typeof raw.get === "function",
|
|
618
|
+
canWrite: typeof raw.set === "function"
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
if (typeof raw.value === "function") {
|
|
622
|
+
const fn = raw.value;
|
|
623
|
+
return {
|
|
624
|
+
kind: "method",
|
|
625
|
+
name,
|
|
626
|
+
value: fn,
|
|
627
|
+
invoke: (thisArg, ...args) => fn.apply(thisArg, args)
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
if ("value" in raw) {
|
|
631
|
+
return {
|
|
632
|
+
kind: "data",
|
|
633
|
+
name,
|
|
634
|
+
value: raw.value,
|
|
635
|
+
writable: (_c = raw.writable) != null ? _c : false,
|
|
636
|
+
configurable: (_d = raw.configurable) != null ? _d : false,
|
|
637
|
+
enumerable: (_e = raw.enumerable) != null ? _e : false
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
return void 0;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// src/utility/Lazy.ts
|
|
644
|
+
var Lazy = class {
|
|
645
|
+
constructor(factory) {
|
|
646
|
+
this.factory = factory;
|
|
647
|
+
/** The lazily initialized value, or `undefined` if not yet initialized. */
|
|
648
|
+
this.lazyValue = void 0;
|
|
649
|
+
/** Indicates whether the value has been initialized. */
|
|
650
|
+
this.initialized = false;
|
|
651
|
+
}
|
|
652
|
+
/** Returns the lazily initialized value, initializing it if necessary. */
|
|
653
|
+
get value() {
|
|
654
|
+
if (!this.initialized) {
|
|
655
|
+
this.lazyValue = this.factory();
|
|
656
|
+
this.initialized = true;
|
|
657
|
+
}
|
|
658
|
+
return this.lazyValue;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
export {
|
|
663
|
+
__decoratorStart,
|
|
664
|
+
__decoratorMetadata,
|
|
665
|
+
__runInitializers,
|
|
666
|
+
__decorateElement,
|
|
667
|
+
__asyncGenerator,
|
|
668
|
+
nameof,
|
|
669
|
+
TyneqError,
|
|
670
|
+
ArgumentError,
|
|
671
|
+
ArgumentNullError,
|
|
672
|
+
ArgumentOutOfRangeError,
|
|
673
|
+
ArgumentTypeError,
|
|
674
|
+
TypeGuardUtility,
|
|
675
|
+
ArgumentUtility,
|
|
676
|
+
ReflectionError,
|
|
677
|
+
ReflectionContext,
|
|
678
|
+
reflect,
|
|
679
|
+
Lazy
|
|
680
|
+
};
|