inferred-types 0.24.3 → 0.26.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/index.d.ts +179 -34
- package/dist/index.js +337 -255
- package/dist/index.mjs +332 -252
- package/package.json +2 -1
- package/src/types/TypeInfo/Includes.ts +34 -0
- package/src/types/TypeInfo/IsBooleanLiteral.ts +7 -0
- package/src/types/TypeInfo/IsLiteral.ts +20 -0
- package/src/types/TypeInfo/IsNumericLiteral.ts +7 -0
- package/src/types/TypeInfo/IsStringLiteral.ts +7 -0
- package/src/types/TypeInfo/index.ts +5 -0
- package/src/types/functions/LogicFunction.ts +4 -0
- package/src/types/functions/index.ts +1 -0
- package/src/types/index.ts +1 -1
- package/src/utility/boolean-logic/and.ts +15 -0
- package/src/utility/boolean-logic/filter.ts +268 -0
- package/src/utility/boolean-logic/index.ts +4 -0
- package/src/utility/boolean-logic/not.ts +15 -0
- package/src/utility/boolean-logic/or.ts +15 -0
- package/src/utility/index.ts +1 -1
- package/src/utility/lists/asArray.ts +34 -0
- package/src/utility/lists/index.ts +1 -0
- package/tests/Includes-spec.ts +26 -5
- package/tests/TypeInfo/IsLiteral.spec.ts +49 -0
- package/tests/boolean-logic/boolean.spec.ts +21 -0
- package/tests/boolean-logic/filter.spec.ts +52 -0
- package/tests/lists/asArray.test.ts +91 -0
- package/tsconfig.json +8 -0
- package/vitest.config.ts +7 -0
- package/src/types/Includes.ts +0 -5
- package/src/utility/map-reduce/filter.ts +0 -35
- package/src/utility/map-reduce/index.ts +0 -12
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(src_exports, {
|
|
|
29
29
|
api: () => api,
|
|
30
30
|
arrayToKeyLookup: () => arrayToKeyLookup,
|
|
31
31
|
arrayToObject: () => arrayToObject,
|
|
32
|
+
asArray: () => asArray,
|
|
32
33
|
condition: () => condition,
|
|
33
34
|
createFnWithProps: () => createFnWithProps,
|
|
34
35
|
createMutationFunction: () => createMutationFunction,
|
|
@@ -38,10 +39,9 @@ __export(src_exports, {
|
|
|
38
39
|
dictToKv: () => dictToKv,
|
|
39
40
|
dictionaryTransform: () => dictionaryTransform,
|
|
40
41
|
entries: () => entries,
|
|
41
|
-
|
|
42
|
+
filter: () => filter,
|
|
42
43
|
filterDictArray: () => filterDictArray,
|
|
43
44
|
fnWithProps: () => fnWithProps,
|
|
44
|
-
greater: () => greater,
|
|
45
45
|
groupBy: () => groupBy,
|
|
46
46
|
idLiteral: () => idLiteral,
|
|
47
47
|
idTypeGuard: () => idTypeGuard,
|
|
@@ -51,8 +51,10 @@ __export(src_exports, {
|
|
|
51
51
|
isBoolean: () => isBoolean,
|
|
52
52
|
isFalse: () => isFalse,
|
|
53
53
|
isFunction: () => isFunction,
|
|
54
|
+
isNotFilter: () => isNotFilter,
|
|
54
55
|
isNull: () => isNull,
|
|
55
56
|
isNumber: () => isNumber,
|
|
57
|
+
isNumericFilter: () => isNumericFilter,
|
|
56
58
|
isObject: () => isObject,
|
|
57
59
|
isString: () => isString,
|
|
58
60
|
isSymbol: () => isSymbol,
|
|
@@ -63,11 +65,11 @@ __export(src_exports, {
|
|
|
63
65
|
kindLiteral: () => kindLiteral,
|
|
64
66
|
kv: () => kv,
|
|
65
67
|
kvToDict: () => kvToDict,
|
|
66
|
-
less: () => less,
|
|
67
68
|
literal: () => literal,
|
|
68
69
|
mapTo: () => mapTo,
|
|
69
70
|
mapValues: () => mapValues,
|
|
70
71
|
nameLiteral: () => nameLiteral,
|
|
72
|
+
not: () => not,
|
|
71
73
|
or: () => or,
|
|
72
74
|
randomString: () => randomString,
|
|
73
75
|
readonlyFnWithProps: () => readonlyFnWithProps,
|
|
@@ -167,6 +169,333 @@ var api = (priv) => (pub) => {
|
|
|
167
169
|
return surface;
|
|
168
170
|
};
|
|
169
171
|
|
|
172
|
+
// src/utility/boolean-logic/and.ts
|
|
173
|
+
var and = (...ops) => {
|
|
174
|
+
const fn = (...args) => {
|
|
175
|
+
return [...ops].every((i) => i(...args));
|
|
176
|
+
};
|
|
177
|
+
return fn;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
// src/utility/boolean-logic/or.ts
|
|
181
|
+
var or = (...ops) => {
|
|
182
|
+
const fn = (...args) => {
|
|
183
|
+
return [...ops].some((i) => i(...args));
|
|
184
|
+
};
|
|
185
|
+
return fn;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/utility/boolean-logic/not.ts
|
|
189
|
+
var not = (op) => {
|
|
190
|
+
const fn = (...args) => {
|
|
191
|
+
return !op(...args);
|
|
192
|
+
};
|
|
193
|
+
return fn;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/utility/runtime/condition.ts
|
|
197
|
+
var condition = (c, input) => {
|
|
198
|
+
return c(input);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// src/utility/runtime/ifTypeOf.ts
|
|
202
|
+
function runtimeExtendsCheck(val, base, narrow = false) {
|
|
203
|
+
if (typeof val !== typeof base) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
switch (typeof val) {
|
|
207
|
+
case "boolean":
|
|
208
|
+
case "string":
|
|
209
|
+
case "number":
|
|
210
|
+
case "symbol":
|
|
211
|
+
case "bigint":
|
|
212
|
+
return narrow ? val === base : true;
|
|
213
|
+
case "undefined":
|
|
214
|
+
return true;
|
|
215
|
+
case "function":
|
|
216
|
+
if (narrow) {
|
|
217
|
+
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
218
|
+
}
|
|
219
|
+
return true;
|
|
220
|
+
case "object":
|
|
221
|
+
if (val === null && base === null) {
|
|
222
|
+
return true;
|
|
223
|
+
} else {
|
|
224
|
+
return keys(base).every(
|
|
225
|
+
(i) => runtimeExtendsCheck(val[i], base[i], narrow)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
var ifTypeOf = (val) => ({
|
|
231
|
+
extends: (base) => {
|
|
232
|
+
const valid = runtimeExtendsCheck(val, base, false);
|
|
233
|
+
const trueFalse = valid ? true : false;
|
|
234
|
+
return {
|
|
235
|
+
then: (then) => ({
|
|
236
|
+
else: (elseVal) => {
|
|
237
|
+
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
238
|
+
}
|
|
239
|
+
}),
|
|
240
|
+
else: (elseVal) => valid ? val : elseVal
|
|
241
|
+
} && trueFalse;
|
|
242
|
+
},
|
|
243
|
+
narrowlyExtends: (base) => {
|
|
244
|
+
const valid = runtimeExtendsCheck(val, base, true);
|
|
245
|
+
const trueFalse = valid ? true : false;
|
|
246
|
+
return {
|
|
247
|
+
then: (then) => ({
|
|
248
|
+
else: (elseVal) => {
|
|
249
|
+
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
else: (elseVal) => valid ? val : elseVal
|
|
253
|
+
} && trueFalse;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// src/utility/runtime/conditions/isArray.ts
|
|
258
|
+
function isArray(i) {
|
|
259
|
+
return Array.isArray(i) === true;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/utility/runtime/conditions/isBoolean.ts
|
|
263
|
+
function isBoolean(i) {
|
|
264
|
+
return typeof i === "boolean";
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// src/utility/runtime/conditions/isFalse.ts
|
|
268
|
+
function isFalse(i) {
|
|
269
|
+
return typeof i === "boolean" && !i;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// src/utility/runtime/conditions/isFunction.ts
|
|
273
|
+
function isFunction(input) {
|
|
274
|
+
return typeof input === "function";
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// src/utility/runtime/conditions/isNull.ts
|
|
278
|
+
function isNull(i) {
|
|
279
|
+
return i === null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// src/utility/runtime/conditions/isNumber.ts
|
|
283
|
+
function isNumber(i) {
|
|
284
|
+
return typeof i === "number";
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/utility/runtime/conditions/isObject.ts
|
|
288
|
+
function isObject(i) {
|
|
289
|
+
return typeof i === "object" && i !== null && Array.isArray(i) === false;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/utility/runtime/conditions/isString.ts
|
|
293
|
+
function isString(i) {
|
|
294
|
+
return typeof i === "string";
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/utility/runtime/conditions/isSymbol.ts
|
|
298
|
+
function isSymbol(i) {
|
|
299
|
+
return typeof i === "symbol";
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
// src/utility/runtime/conditions/isTrue.ts
|
|
303
|
+
function isTrue(i) {
|
|
304
|
+
return typeof i === "boolean" && i;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/utility/runtime/conditions/isUndefined.ts
|
|
308
|
+
function isUndefined(i) {
|
|
309
|
+
return typeof i === "undefined";
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/utility/runtime/type.ts
|
|
313
|
+
var typeApi = () => ({
|
|
314
|
+
string: {
|
|
315
|
+
name: "string",
|
|
316
|
+
type: "",
|
|
317
|
+
typeGuard: (v) => isString(v),
|
|
318
|
+
is: isString
|
|
319
|
+
},
|
|
320
|
+
boolean: {
|
|
321
|
+
name: "boolean",
|
|
322
|
+
type: true,
|
|
323
|
+
typeGuard: (v) => isBoolean(v),
|
|
324
|
+
is: isBoolean
|
|
325
|
+
},
|
|
326
|
+
number: {
|
|
327
|
+
name: "number",
|
|
328
|
+
type: 1,
|
|
329
|
+
typeGuard: (v) => isNumber(v),
|
|
330
|
+
is: isNumber
|
|
331
|
+
},
|
|
332
|
+
function: {
|
|
333
|
+
name: "function",
|
|
334
|
+
type: Function,
|
|
335
|
+
typeGuard: (v) => isFunction(v),
|
|
336
|
+
is: isFunction
|
|
337
|
+
},
|
|
338
|
+
null: {
|
|
339
|
+
name: "null",
|
|
340
|
+
type: null,
|
|
341
|
+
typeGuard: (v) => isNull(v),
|
|
342
|
+
is: isNull
|
|
343
|
+
},
|
|
344
|
+
symbol: {
|
|
345
|
+
name: "symbol",
|
|
346
|
+
type: Symbol(),
|
|
347
|
+
typeGuard: (v) => isSymbol(v),
|
|
348
|
+
is: isSymbol
|
|
349
|
+
},
|
|
350
|
+
undefined: {
|
|
351
|
+
name: "undefined",
|
|
352
|
+
type: void 0,
|
|
353
|
+
typeGuard: (v) => isUndefined(v),
|
|
354
|
+
is: isUndefined
|
|
355
|
+
},
|
|
356
|
+
true: {
|
|
357
|
+
name: "true",
|
|
358
|
+
type: true,
|
|
359
|
+
typeGuard: (v) => isTrue(v),
|
|
360
|
+
is: isTrue
|
|
361
|
+
},
|
|
362
|
+
false: {
|
|
363
|
+
name: "false",
|
|
364
|
+
type: false,
|
|
365
|
+
typeGuard: (v) => isFalse(v),
|
|
366
|
+
is: isFalse
|
|
367
|
+
},
|
|
368
|
+
object: {
|
|
369
|
+
name: "object",
|
|
370
|
+
type: {},
|
|
371
|
+
typeGuard: (v) => isObject(v),
|
|
372
|
+
is: isObject
|
|
373
|
+
},
|
|
374
|
+
array: {
|
|
375
|
+
name: "array",
|
|
376
|
+
type: {},
|
|
377
|
+
typeGuard: (v) => isArray(v),
|
|
378
|
+
is: isObject
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
function isType(t) {
|
|
382
|
+
return typeof t === "object" && ["name", "type", "is"].every((i) => Object.keys(t).includes(i));
|
|
383
|
+
}
|
|
384
|
+
function type(fn) {
|
|
385
|
+
const result = fn(typeApi());
|
|
386
|
+
if (!isType(result)) {
|
|
387
|
+
throw new Error(
|
|
388
|
+
`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
return result;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/utility/dictionary/entries.ts
|
|
395
|
+
function entries(obj) {
|
|
396
|
+
const iterable = {
|
|
397
|
+
*[Symbol.iterator]() {
|
|
398
|
+
for (const k of keys(obj)) {
|
|
399
|
+
yield [k, obj[k]];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
return iterable;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// src/utility/runtime/withValue.ts
|
|
407
|
+
function withValue(td) {
|
|
408
|
+
return (obj) => {
|
|
409
|
+
const t = type(td);
|
|
410
|
+
return Object.fromEntries(
|
|
411
|
+
[...entries(obj)].filter(([_key, value]) => {
|
|
412
|
+
return t.typeGuard(value);
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// src/utility/lists/asArray.ts
|
|
419
|
+
var asArray = (thing, _widen) => {
|
|
420
|
+
return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// src/utility/boolean-logic/filter.ts
|
|
424
|
+
function isNotFilter(f) {
|
|
425
|
+
return typeof f === "object" && "not" in f;
|
|
426
|
+
}
|
|
427
|
+
function isNumericFilter(filter2) {
|
|
428
|
+
return "equals" in filter2 || "notEqual" in filter2 || "greaterThan" in filter2 || "lessThan" in filter2 ? true : false;
|
|
429
|
+
}
|
|
430
|
+
var numericOps = (config, boolLogic) => {
|
|
431
|
+
const equals = (n) => {
|
|
432
|
+
const f = asArray(n);
|
|
433
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => i === input)];
|
|
434
|
+
};
|
|
435
|
+
const notEqual = (n) => {
|
|
436
|
+
const f = asArray(n);
|
|
437
|
+
return f.length === 0 ? [] : [(input) => f.every((i) => i !== input)];
|
|
438
|
+
};
|
|
439
|
+
const greaterThan = (n) => {
|
|
440
|
+
const val = [(input) => input !== void 0 && input > n];
|
|
441
|
+
return val;
|
|
442
|
+
};
|
|
443
|
+
const lessThan = (n) => {
|
|
444
|
+
const val = [(input) => input !== void 0 && input < n];
|
|
445
|
+
return val;
|
|
446
|
+
};
|
|
447
|
+
const conditions = [
|
|
448
|
+
..."equals" in config ? equals(config.equals) : [],
|
|
449
|
+
..."notEqual" in config ? notEqual(config.notEqual) : [],
|
|
450
|
+
..."greaterThan" in config ? greaterThan(config.greaterThan) : [],
|
|
451
|
+
..."lessThan" in config ? lessThan(config.lessThan) : []
|
|
452
|
+
];
|
|
453
|
+
const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
|
|
454
|
+
return combined;
|
|
455
|
+
};
|
|
456
|
+
var stringOps = (config, boolLogic) => {
|
|
457
|
+
const startsWith = (n) => {
|
|
458
|
+
const f = asArray(n);
|
|
459
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.startsWith(i))];
|
|
460
|
+
};
|
|
461
|
+
const endsWith = (n) => {
|
|
462
|
+
const f = asArray(n);
|
|
463
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.endsWith(i))];
|
|
464
|
+
};
|
|
465
|
+
const contains = (n) => {
|
|
466
|
+
const f = asArray(n);
|
|
467
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.includes(i))];
|
|
468
|
+
};
|
|
469
|
+
const conditions = [
|
|
470
|
+
..."startsWith" in config ? startsWith(config.startsWith) : [],
|
|
471
|
+
..."endsWith" in config ? endsWith(config.endsWith) : [],
|
|
472
|
+
..."contains" in config ? contains(config.contains) : []
|
|
473
|
+
];
|
|
474
|
+
const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
|
|
475
|
+
return combined;
|
|
476
|
+
};
|
|
477
|
+
var filterFn = (defn, logicCombinator, ifUndefined = "no-impact") => {
|
|
478
|
+
const config = isNotFilter(defn) ? defn["not"] : defn;
|
|
479
|
+
const filter2 = (input) => {
|
|
480
|
+
const undefValue = ifUndefined === "no-impact" ? logicCombinator === "AND" ? true : false : ifUndefined;
|
|
481
|
+
let flag;
|
|
482
|
+
if (typeof input === "undefined") {
|
|
483
|
+
flag = undefValue;
|
|
484
|
+
} else if (isNumericFilter(config)) {
|
|
485
|
+
const fn = numericOps(config, logicCombinator);
|
|
486
|
+
flag = isNotFilter(defn) ? !fn(input) : fn(input);
|
|
487
|
+
} else {
|
|
488
|
+
const fn = stringOps(config, logicCombinator);
|
|
489
|
+
flag = isNotFilter(defn) ? !fn(input) : fn(input);
|
|
490
|
+
}
|
|
491
|
+
return flag;
|
|
492
|
+
};
|
|
493
|
+
return filter2;
|
|
494
|
+
};
|
|
495
|
+
var filter = (config, logicCombinator = "AND", ifUndefined = "no-impact") => {
|
|
496
|
+
return filterFn(config, logicCombinator, ifUndefined);
|
|
497
|
+
};
|
|
498
|
+
|
|
170
499
|
// src/utility/dictionary/arrayToKeyLookup.ts
|
|
171
500
|
function arrayToKeyLookup(...keys2) {
|
|
172
501
|
const obj = {};
|
|
@@ -242,18 +571,6 @@ var dictArr = (...dicts) => {
|
|
|
242
571
|
return api2;
|
|
243
572
|
};
|
|
244
573
|
|
|
245
|
-
// src/utility/dictionary/entries.ts
|
|
246
|
-
function entries(obj) {
|
|
247
|
-
const iterable = {
|
|
248
|
-
*[Symbol.iterator]() {
|
|
249
|
-
for (const k of keys(obj)) {
|
|
250
|
-
yield [k, obj[k]];
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
return iterable;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
574
|
// src/utility/dictionary/mapValues.ts
|
|
258
575
|
function mapValues(obj, valueMapper) {
|
|
259
576
|
return Object.fromEntries(
|
|
@@ -415,33 +732,6 @@ function literal(obj) {
|
|
|
415
732
|
return obj;
|
|
416
733
|
}
|
|
417
734
|
|
|
418
|
-
// src/utility/map-reduce/filter.ts
|
|
419
|
-
var equals = (field, val) => ({
|
|
420
|
-
kind: "Equals",
|
|
421
|
-
field,
|
|
422
|
-
val
|
|
423
|
-
});
|
|
424
|
-
var greater = (field, val) => ({
|
|
425
|
-
kind: "Greater",
|
|
426
|
-
field,
|
|
427
|
-
val
|
|
428
|
-
});
|
|
429
|
-
var less = (field, val) => ({
|
|
430
|
-
kind: "Less",
|
|
431
|
-
field,
|
|
432
|
-
val
|
|
433
|
-
});
|
|
434
|
-
var and = (a, b) => ({
|
|
435
|
-
kind: "And",
|
|
436
|
-
a,
|
|
437
|
-
b
|
|
438
|
-
});
|
|
439
|
-
var or = (a, b) => ({
|
|
440
|
-
kind: "Or",
|
|
441
|
-
a,
|
|
442
|
-
b
|
|
443
|
-
});
|
|
444
|
-
|
|
445
735
|
// src/utility/modelling/Model.ts
|
|
446
736
|
function Model(name) {
|
|
447
737
|
return {
|
|
@@ -459,216 +749,6 @@ function Model(name) {
|
|
|
459
749
|
}
|
|
460
750
|
};
|
|
461
751
|
}
|
|
462
|
-
|
|
463
|
-
// src/utility/runtime/condition.ts
|
|
464
|
-
var condition = (c, input) => {
|
|
465
|
-
return c(input);
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
// src/utility/runtime/ifTypeOf.ts
|
|
469
|
-
function runtimeExtendsCheck(val, base, narrow = false) {
|
|
470
|
-
if (typeof val !== typeof base) {
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
switch (typeof val) {
|
|
474
|
-
case "boolean":
|
|
475
|
-
case "string":
|
|
476
|
-
case "number":
|
|
477
|
-
case "symbol":
|
|
478
|
-
case "bigint":
|
|
479
|
-
return narrow ? val === base : true;
|
|
480
|
-
case "undefined":
|
|
481
|
-
return true;
|
|
482
|
-
case "function":
|
|
483
|
-
if (narrow) {
|
|
484
|
-
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
485
|
-
}
|
|
486
|
-
return true;
|
|
487
|
-
case "object":
|
|
488
|
-
if (val === null && base === null) {
|
|
489
|
-
return true;
|
|
490
|
-
} else {
|
|
491
|
-
return keys(base).every(
|
|
492
|
-
(i) => runtimeExtendsCheck(val[i], base[i], narrow)
|
|
493
|
-
);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
var ifTypeOf = (val) => ({
|
|
498
|
-
extends: (base) => {
|
|
499
|
-
const valid = runtimeExtendsCheck(val, base, false);
|
|
500
|
-
const trueFalse = valid ? true : false;
|
|
501
|
-
return {
|
|
502
|
-
then: (then) => ({
|
|
503
|
-
else: (elseVal) => {
|
|
504
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
505
|
-
}
|
|
506
|
-
}),
|
|
507
|
-
else: (elseVal) => valid ? val : elseVal
|
|
508
|
-
} && trueFalse;
|
|
509
|
-
},
|
|
510
|
-
narrowlyExtends: (base) => {
|
|
511
|
-
const valid = runtimeExtendsCheck(val, base, true);
|
|
512
|
-
const trueFalse = valid ? true : false;
|
|
513
|
-
return {
|
|
514
|
-
then: (then) => ({
|
|
515
|
-
else: (elseVal) => {
|
|
516
|
-
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
517
|
-
}
|
|
518
|
-
}),
|
|
519
|
-
else: (elseVal) => valid ? val : elseVal
|
|
520
|
-
} && trueFalse;
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
// src/utility/runtime/conditions/isArray.ts
|
|
525
|
-
function isArray(i) {
|
|
526
|
-
return Array.isArray(i) === true;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
// src/utility/runtime/conditions/isBoolean.ts
|
|
530
|
-
function isBoolean(i) {
|
|
531
|
-
return typeof i === "boolean";
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
// src/utility/runtime/conditions/isFalse.ts
|
|
535
|
-
function isFalse(i) {
|
|
536
|
-
return typeof i === "boolean" && !i;
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// src/utility/runtime/conditions/isFunction.ts
|
|
540
|
-
function isFunction(input) {
|
|
541
|
-
return typeof input === "function";
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// src/utility/runtime/conditions/isNull.ts
|
|
545
|
-
function isNull(i) {
|
|
546
|
-
return i === null;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// src/utility/runtime/conditions/isNumber.ts
|
|
550
|
-
function isNumber(i) {
|
|
551
|
-
return typeof i === "number";
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// src/utility/runtime/conditions/isObject.ts
|
|
555
|
-
function isObject(i) {
|
|
556
|
-
return typeof i === "object" && i !== null && Array.isArray(i) === false;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// src/utility/runtime/conditions/isString.ts
|
|
560
|
-
function isString(i) {
|
|
561
|
-
return typeof i === "string";
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
// src/utility/runtime/conditions/isSymbol.ts
|
|
565
|
-
function isSymbol(i) {
|
|
566
|
-
return typeof i === "symbol";
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// src/utility/runtime/conditions/isTrue.ts
|
|
570
|
-
function isTrue(i) {
|
|
571
|
-
return typeof i === "boolean" && i;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
// src/utility/runtime/conditions/isUndefined.ts
|
|
575
|
-
function isUndefined(i) {
|
|
576
|
-
return typeof i === "undefined";
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
// src/utility/runtime/type.ts
|
|
580
|
-
var typeApi = () => ({
|
|
581
|
-
string: {
|
|
582
|
-
name: "string",
|
|
583
|
-
type: "",
|
|
584
|
-
typeGuard: (v) => isString(v),
|
|
585
|
-
is: isString
|
|
586
|
-
},
|
|
587
|
-
boolean: {
|
|
588
|
-
name: "boolean",
|
|
589
|
-
type: true,
|
|
590
|
-
typeGuard: (v) => isBoolean(v),
|
|
591
|
-
is: isBoolean
|
|
592
|
-
},
|
|
593
|
-
number: {
|
|
594
|
-
name: "number",
|
|
595
|
-
type: 1,
|
|
596
|
-
typeGuard: (v) => isNumber(v),
|
|
597
|
-
is: isNumber
|
|
598
|
-
},
|
|
599
|
-
function: {
|
|
600
|
-
name: "function",
|
|
601
|
-
type: Function,
|
|
602
|
-
typeGuard: (v) => isFunction(v),
|
|
603
|
-
is: isFunction
|
|
604
|
-
},
|
|
605
|
-
null: {
|
|
606
|
-
name: "null",
|
|
607
|
-
type: null,
|
|
608
|
-
typeGuard: (v) => isNull(v),
|
|
609
|
-
is: isNull
|
|
610
|
-
},
|
|
611
|
-
symbol: {
|
|
612
|
-
name: "symbol",
|
|
613
|
-
type: Symbol(),
|
|
614
|
-
typeGuard: (v) => isSymbol(v),
|
|
615
|
-
is: isSymbol
|
|
616
|
-
},
|
|
617
|
-
undefined: {
|
|
618
|
-
name: "undefined",
|
|
619
|
-
type: void 0,
|
|
620
|
-
typeGuard: (v) => isUndefined(v),
|
|
621
|
-
is: isUndefined
|
|
622
|
-
},
|
|
623
|
-
true: {
|
|
624
|
-
name: "true",
|
|
625
|
-
type: true,
|
|
626
|
-
typeGuard: (v) => isTrue(v),
|
|
627
|
-
is: isTrue
|
|
628
|
-
},
|
|
629
|
-
false: {
|
|
630
|
-
name: "false",
|
|
631
|
-
type: false,
|
|
632
|
-
typeGuard: (v) => isFalse(v),
|
|
633
|
-
is: isFalse
|
|
634
|
-
},
|
|
635
|
-
object: {
|
|
636
|
-
name: "object",
|
|
637
|
-
type: {},
|
|
638
|
-
typeGuard: (v) => isObject(v),
|
|
639
|
-
is: isObject
|
|
640
|
-
},
|
|
641
|
-
array: {
|
|
642
|
-
name: "array",
|
|
643
|
-
type: {},
|
|
644
|
-
typeGuard: (v) => isArray(v),
|
|
645
|
-
is: isObject
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
function isType(t) {
|
|
649
|
-
return typeof t === "object" && ["name", "type", "is"].every((i) => Object.keys(t).includes(i));
|
|
650
|
-
}
|
|
651
|
-
function type(fn) {
|
|
652
|
-
const result = fn(typeApi());
|
|
653
|
-
if (!isType(result)) {
|
|
654
|
-
throw new Error(
|
|
655
|
-
`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
return result;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
// src/utility/runtime/withValue.ts
|
|
662
|
-
function withValue(td) {
|
|
663
|
-
return (obj) => {
|
|
664
|
-
const t = type(td);
|
|
665
|
-
return Object.fromEntries(
|
|
666
|
-
[...entries(obj)].filter(([_key, value]) => {
|
|
667
|
-
return t.typeGuard(value);
|
|
668
|
-
})
|
|
669
|
-
);
|
|
670
|
-
};
|
|
671
|
-
}
|
|
672
752
|
// Annotate the CommonJS export names for ESM import in node:
|
|
673
753
|
0 && (module.exports = {
|
|
674
754
|
Configurator,
|
|
@@ -680,6 +760,7 @@ function withValue(td) {
|
|
|
680
760
|
api,
|
|
681
761
|
arrayToKeyLookup,
|
|
682
762
|
arrayToObject,
|
|
763
|
+
asArray,
|
|
683
764
|
condition,
|
|
684
765
|
createFnWithProps,
|
|
685
766
|
createMutationFunction,
|
|
@@ -689,10 +770,9 @@ function withValue(td) {
|
|
|
689
770
|
dictToKv,
|
|
690
771
|
dictionaryTransform,
|
|
691
772
|
entries,
|
|
692
|
-
|
|
773
|
+
filter,
|
|
693
774
|
filterDictArray,
|
|
694
775
|
fnWithProps,
|
|
695
|
-
greater,
|
|
696
776
|
groupBy,
|
|
697
777
|
idLiteral,
|
|
698
778
|
idTypeGuard,
|
|
@@ -702,8 +782,10 @@ function withValue(td) {
|
|
|
702
782
|
isBoolean,
|
|
703
783
|
isFalse,
|
|
704
784
|
isFunction,
|
|
785
|
+
isNotFilter,
|
|
705
786
|
isNull,
|
|
706
787
|
isNumber,
|
|
788
|
+
isNumericFilter,
|
|
707
789
|
isObject,
|
|
708
790
|
isString,
|
|
709
791
|
isSymbol,
|
|
@@ -714,11 +796,11 @@ function withValue(td) {
|
|
|
714
796
|
kindLiteral,
|
|
715
797
|
kv,
|
|
716
798
|
kvToDict,
|
|
717
|
-
less,
|
|
718
799
|
literal,
|
|
719
800
|
mapTo,
|
|
720
801
|
mapValues,
|
|
721
802
|
nameLiteral,
|
|
803
|
+
not,
|
|
722
804
|
or,
|
|
723
805
|
randomString,
|
|
724
806
|
readonlyFnWithProps,
|