inferred-types 0.25.0 → 0.27.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/.vscode/settings.json +1 -0
- package/dist/index.d.ts +308 -84
- package/dist/index.js +378 -262
- package/dist/index.mjs +370 -259
- package/package.json +1 -1
- package/src/types/alphabetic/Cardinality.ts +80 -0
- package/src/types/alphabetic/index.ts +1 -0
- package/src/types/dictionary/MapTo.ts +128 -15
- package/src/types/functions/LogicFunction.ts +4 -0
- package/src/types/functions/index.ts +1 -0
- package/src/types/index.ts +1 -0
- package/src/types/literal-unions/OptRequired.ts +4 -0
- package/src/types/literal-unions/index.ts +1 -0
- package/src/types/string-literals/Replace.ts +8 -4
- 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/dictionary/mapTo.ts +117 -30
- 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/boolean-logic/boolean.spec.ts +21 -0
- package/tests/boolean-logic/filter.spec.ts +52 -0
- package/tests/createFnWithProps.spec.ts +1 -0
- package/tests/dictionary/mapTo.test.ts +159 -92
- package/tests/lists/asArray.test.ts +91 -0
- package/src/utility/map-reduce/filter.ts +0 -35
- package/src/utility/map-reduce/index.ts +0 -12
package/dist/index.js
CHANGED
|
@@ -23,12 +23,14 @@ __export(src_exports, {
|
|
|
23
23
|
Configurator: () => Configurator,
|
|
24
24
|
ExplicitFunction: () => ExplicitFunction,
|
|
25
25
|
FluentConfigurator: () => FluentConfigurator,
|
|
26
|
+
MapDirection: () => MapDirection,
|
|
26
27
|
Model: () => Model,
|
|
27
28
|
MutationIdentity: () => MutationIdentity,
|
|
28
29
|
and: () => and,
|
|
29
30
|
api: () => api,
|
|
30
31
|
arrayToKeyLookup: () => arrayToKeyLookup,
|
|
31
32
|
arrayToObject: () => arrayToObject,
|
|
33
|
+
asArray: () => asArray,
|
|
32
34
|
condition: () => condition,
|
|
33
35
|
createFnWithProps: () => createFnWithProps,
|
|
34
36
|
createMutationFunction: () => createMutationFunction,
|
|
@@ -38,10 +40,9 @@ __export(src_exports, {
|
|
|
38
40
|
dictToKv: () => dictToKv,
|
|
39
41
|
dictionaryTransform: () => dictionaryTransform,
|
|
40
42
|
entries: () => entries,
|
|
41
|
-
|
|
43
|
+
filter: () => filter,
|
|
42
44
|
filterDictArray: () => filterDictArray,
|
|
43
45
|
fnWithProps: () => fnWithProps,
|
|
44
|
-
greater: () => greater,
|
|
45
46
|
groupBy: () => groupBy,
|
|
46
47
|
idLiteral: () => idLiteral,
|
|
47
48
|
idTypeGuard: () => idTypeGuard,
|
|
@@ -51,8 +52,10 @@ __export(src_exports, {
|
|
|
51
52
|
isBoolean: () => isBoolean,
|
|
52
53
|
isFalse: () => isFalse,
|
|
53
54
|
isFunction: () => isFunction,
|
|
55
|
+
isNotFilter: () => isNotFilter,
|
|
54
56
|
isNull: () => isNull,
|
|
55
57
|
isNumber: () => isNumber,
|
|
58
|
+
isNumericFilter: () => isNumericFilter,
|
|
56
59
|
isObject: () => isObject,
|
|
57
60
|
isString: () => isString,
|
|
58
61
|
isSymbol: () => isSymbol,
|
|
@@ -63,11 +66,13 @@ __export(src_exports, {
|
|
|
63
66
|
kindLiteral: () => kindLiteral,
|
|
64
67
|
kv: () => kv,
|
|
65
68
|
kvToDict: () => kvToDict,
|
|
66
|
-
less: () => less,
|
|
67
69
|
literal: () => literal,
|
|
68
70
|
mapTo: () => mapTo,
|
|
71
|
+
mapToDict: () => mapToDict,
|
|
72
|
+
mapToFn: () => mapToFn,
|
|
69
73
|
mapValues: () => mapValues,
|
|
70
74
|
nameLiteral: () => nameLiteral,
|
|
75
|
+
not: () => not,
|
|
71
76
|
or: () => or,
|
|
72
77
|
randomString: () => randomString,
|
|
73
78
|
readonlyFnWithProps: () => readonlyFnWithProps,
|
|
@@ -124,6 +129,14 @@ var valueTypes = {
|
|
|
124
129
|
literalArray: (arr) => [arr, true]
|
|
125
130
|
};
|
|
126
131
|
|
|
132
|
+
// src/types/dictionary/MapTo.ts
|
|
133
|
+
var MapDirection = /* @__PURE__ */ ((MapDirection2) => {
|
|
134
|
+
MapDirection2["OneToMany"] = "I -> O[]";
|
|
135
|
+
MapDirection2["OneToOne"] = "I -> O";
|
|
136
|
+
MapDirection2["ManyToOne"] = "I[] -> O";
|
|
137
|
+
return MapDirection2;
|
|
138
|
+
})(MapDirection || {});
|
|
139
|
+
|
|
127
140
|
// src/utility/keys.ts
|
|
128
141
|
function keys(obj, ...without) {
|
|
129
142
|
const v = without.length > 0 ? Object.keys(obj).filter((k) => !without.includes(k)) : Object.keys(obj);
|
|
@@ -167,6 +180,333 @@ var api = (priv) => (pub) => {
|
|
|
167
180
|
return surface;
|
|
168
181
|
};
|
|
169
182
|
|
|
183
|
+
// src/utility/boolean-logic/and.ts
|
|
184
|
+
var and = (...ops) => {
|
|
185
|
+
const fn = (...args) => {
|
|
186
|
+
return [...ops].every((i) => i(...args));
|
|
187
|
+
};
|
|
188
|
+
return fn;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/utility/boolean-logic/or.ts
|
|
192
|
+
var or = (...ops) => {
|
|
193
|
+
const fn = (...args) => {
|
|
194
|
+
return [...ops].some((i) => i(...args));
|
|
195
|
+
};
|
|
196
|
+
return fn;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
// src/utility/boolean-logic/not.ts
|
|
200
|
+
var not = (op) => {
|
|
201
|
+
const fn = (...args) => {
|
|
202
|
+
return !op(...args);
|
|
203
|
+
};
|
|
204
|
+
return fn;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// src/utility/runtime/condition.ts
|
|
208
|
+
var condition = (c, input) => {
|
|
209
|
+
return c(input);
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/utility/runtime/ifTypeOf.ts
|
|
213
|
+
function runtimeExtendsCheck(val, base, narrow = false) {
|
|
214
|
+
if (typeof val !== typeof base) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
switch (typeof val) {
|
|
218
|
+
case "boolean":
|
|
219
|
+
case "string":
|
|
220
|
+
case "number":
|
|
221
|
+
case "symbol":
|
|
222
|
+
case "bigint":
|
|
223
|
+
return narrow ? val === base : true;
|
|
224
|
+
case "undefined":
|
|
225
|
+
return true;
|
|
226
|
+
case "function":
|
|
227
|
+
if (narrow) {
|
|
228
|
+
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
229
|
+
}
|
|
230
|
+
return true;
|
|
231
|
+
case "object":
|
|
232
|
+
if (val === null && base === null) {
|
|
233
|
+
return true;
|
|
234
|
+
} else {
|
|
235
|
+
return keys(base).every(
|
|
236
|
+
(i) => runtimeExtendsCheck(val[i], base[i], narrow)
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
var ifTypeOf = (val) => ({
|
|
242
|
+
extends: (base) => {
|
|
243
|
+
const valid = runtimeExtendsCheck(val, base, false);
|
|
244
|
+
const trueFalse = valid ? true : false;
|
|
245
|
+
return {
|
|
246
|
+
then: (then) => ({
|
|
247
|
+
else: (elseVal) => {
|
|
248
|
+
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
251
|
+
else: (elseVal) => valid ? val : elseVal
|
|
252
|
+
} && trueFalse;
|
|
253
|
+
},
|
|
254
|
+
narrowlyExtends: (base) => {
|
|
255
|
+
const valid = runtimeExtendsCheck(val, base, true);
|
|
256
|
+
const trueFalse = valid ? true : false;
|
|
257
|
+
return {
|
|
258
|
+
then: (then) => ({
|
|
259
|
+
else: (elseVal) => {
|
|
260
|
+
return valid ? typeof then === "undefined" ? val : then : elseVal;
|
|
261
|
+
}
|
|
262
|
+
}),
|
|
263
|
+
else: (elseVal) => valid ? val : elseVal
|
|
264
|
+
} && trueFalse;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// src/utility/runtime/conditions/isArray.ts
|
|
269
|
+
function isArray(i) {
|
|
270
|
+
return Array.isArray(i) === true;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/utility/runtime/conditions/isBoolean.ts
|
|
274
|
+
function isBoolean(i) {
|
|
275
|
+
return typeof i === "boolean";
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// src/utility/runtime/conditions/isFalse.ts
|
|
279
|
+
function isFalse(i) {
|
|
280
|
+
return typeof i === "boolean" && !i;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// src/utility/runtime/conditions/isFunction.ts
|
|
284
|
+
function isFunction(input) {
|
|
285
|
+
return typeof input === "function";
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// src/utility/runtime/conditions/isNull.ts
|
|
289
|
+
function isNull(i) {
|
|
290
|
+
return i === null;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/utility/runtime/conditions/isNumber.ts
|
|
294
|
+
function isNumber(i) {
|
|
295
|
+
return typeof i === "number";
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// src/utility/runtime/conditions/isObject.ts
|
|
299
|
+
function isObject(i) {
|
|
300
|
+
return typeof i === "object" && i !== null && Array.isArray(i) === false;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// src/utility/runtime/conditions/isString.ts
|
|
304
|
+
function isString(i) {
|
|
305
|
+
return typeof i === "string";
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// src/utility/runtime/conditions/isSymbol.ts
|
|
309
|
+
function isSymbol(i) {
|
|
310
|
+
return typeof i === "symbol";
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// src/utility/runtime/conditions/isTrue.ts
|
|
314
|
+
function isTrue(i) {
|
|
315
|
+
return typeof i === "boolean" && i;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/utility/runtime/conditions/isUndefined.ts
|
|
319
|
+
function isUndefined(i) {
|
|
320
|
+
return typeof i === "undefined";
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/utility/runtime/type.ts
|
|
324
|
+
var typeApi = () => ({
|
|
325
|
+
string: {
|
|
326
|
+
name: "string",
|
|
327
|
+
type: "",
|
|
328
|
+
typeGuard: (v) => isString(v),
|
|
329
|
+
is: isString
|
|
330
|
+
},
|
|
331
|
+
boolean: {
|
|
332
|
+
name: "boolean",
|
|
333
|
+
type: true,
|
|
334
|
+
typeGuard: (v) => isBoolean(v),
|
|
335
|
+
is: isBoolean
|
|
336
|
+
},
|
|
337
|
+
number: {
|
|
338
|
+
name: "number",
|
|
339
|
+
type: 1,
|
|
340
|
+
typeGuard: (v) => isNumber(v),
|
|
341
|
+
is: isNumber
|
|
342
|
+
},
|
|
343
|
+
function: {
|
|
344
|
+
name: "function",
|
|
345
|
+
type: Function,
|
|
346
|
+
typeGuard: (v) => isFunction(v),
|
|
347
|
+
is: isFunction
|
|
348
|
+
},
|
|
349
|
+
null: {
|
|
350
|
+
name: "null",
|
|
351
|
+
type: null,
|
|
352
|
+
typeGuard: (v) => isNull(v),
|
|
353
|
+
is: isNull
|
|
354
|
+
},
|
|
355
|
+
symbol: {
|
|
356
|
+
name: "symbol",
|
|
357
|
+
type: Symbol(),
|
|
358
|
+
typeGuard: (v) => isSymbol(v),
|
|
359
|
+
is: isSymbol
|
|
360
|
+
},
|
|
361
|
+
undefined: {
|
|
362
|
+
name: "undefined",
|
|
363
|
+
type: void 0,
|
|
364
|
+
typeGuard: (v) => isUndefined(v),
|
|
365
|
+
is: isUndefined
|
|
366
|
+
},
|
|
367
|
+
true: {
|
|
368
|
+
name: "true",
|
|
369
|
+
type: true,
|
|
370
|
+
typeGuard: (v) => isTrue(v),
|
|
371
|
+
is: isTrue
|
|
372
|
+
},
|
|
373
|
+
false: {
|
|
374
|
+
name: "false",
|
|
375
|
+
type: false,
|
|
376
|
+
typeGuard: (v) => isFalse(v),
|
|
377
|
+
is: isFalse
|
|
378
|
+
},
|
|
379
|
+
object: {
|
|
380
|
+
name: "object",
|
|
381
|
+
type: {},
|
|
382
|
+
typeGuard: (v) => isObject(v),
|
|
383
|
+
is: isObject
|
|
384
|
+
},
|
|
385
|
+
array: {
|
|
386
|
+
name: "array",
|
|
387
|
+
type: {},
|
|
388
|
+
typeGuard: (v) => isArray(v),
|
|
389
|
+
is: isObject
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
function isType(t) {
|
|
393
|
+
return typeof t === "object" && ["name", "type", "is"].every((i) => Object.keys(t).includes(i));
|
|
394
|
+
}
|
|
395
|
+
function type(fn) {
|
|
396
|
+
const result = fn(typeApi());
|
|
397
|
+
if (!isType(result)) {
|
|
398
|
+
throw new Error(
|
|
399
|
+
`When using type(), the callback passed in returned an invalid type! Value returned was: ${result}`
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
return result;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/utility/dictionary/entries.ts
|
|
406
|
+
function entries(obj) {
|
|
407
|
+
const iterable = {
|
|
408
|
+
*[Symbol.iterator]() {
|
|
409
|
+
for (const k of keys(obj)) {
|
|
410
|
+
yield [k, obj[k]];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
return iterable;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// src/utility/runtime/withValue.ts
|
|
418
|
+
function withValue(td) {
|
|
419
|
+
return (obj) => {
|
|
420
|
+
const t = type(td);
|
|
421
|
+
return Object.fromEntries(
|
|
422
|
+
[...entries(obj)].filter(([_key, value]) => {
|
|
423
|
+
return t.typeGuard(value);
|
|
424
|
+
})
|
|
425
|
+
);
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/utility/lists/asArray.ts
|
|
430
|
+
var asArray = (thing, _widen) => {
|
|
431
|
+
return isArray(thing) ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// src/utility/boolean-logic/filter.ts
|
|
435
|
+
function isNotFilter(f) {
|
|
436
|
+
return typeof f === "object" && "not" in f;
|
|
437
|
+
}
|
|
438
|
+
function isNumericFilter(filter2) {
|
|
439
|
+
return "equals" in filter2 || "notEqual" in filter2 || "greaterThan" in filter2 || "lessThan" in filter2 ? true : false;
|
|
440
|
+
}
|
|
441
|
+
var numericOps = (config, boolLogic) => {
|
|
442
|
+
const equals = (n) => {
|
|
443
|
+
const f = asArray(n);
|
|
444
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => i === input)];
|
|
445
|
+
};
|
|
446
|
+
const notEqual = (n) => {
|
|
447
|
+
const f = asArray(n);
|
|
448
|
+
return f.length === 0 ? [] : [(input) => f.every((i) => i !== input)];
|
|
449
|
+
};
|
|
450
|
+
const greaterThan = (n) => {
|
|
451
|
+
const val = [(input) => input !== void 0 && input > n];
|
|
452
|
+
return val;
|
|
453
|
+
};
|
|
454
|
+
const lessThan = (n) => {
|
|
455
|
+
const val = [(input) => input !== void 0 && input < n];
|
|
456
|
+
return val;
|
|
457
|
+
};
|
|
458
|
+
const conditions = [
|
|
459
|
+
..."equals" in config ? equals(config.equals) : [],
|
|
460
|
+
..."notEqual" in config ? notEqual(config.notEqual) : [],
|
|
461
|
+
..."greaterThan" in config ? greaterThan(config.greaterThan) : [],
|
|
462
|
+
..."lessThan" in config ? lessThan(config.lessThan) : []
|
|
463
|
+
];
|
|
464
|
+
const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
|
|
465
|
+
return combined;
|
|
466
|
+
};
|
|
467
|
+
var stringOps = (config, boolLogic) => {
|
|
468
|
+
const startsWith = (n) => {
|
|
469
|
+
const f = asArray(n);
|
|
470
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.startsWith(i))];
|
|
471
|
+
};
|
|
472
|
+
const endsWith = (n) => {
|
|
473
|
+
const f = asArray(n);
|
|
474
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.endsWith(i))];
|
|
475
|
+
};
|
|
476
|
+
const contains = (n) => {
|
|
477
|
+
const f = asArray(n);
|
|
478
|
+
return f.length === 0 ? [] : [(input) => f.some((i) => input == null ? void 0 : input.includes(i))];
|
|
479
|
+
};
|
|
480
|
+
const conditions = [
|
|
481
|
+
..."startsWith" in config ? startsWith(config.startsWith) : [],
|
|
482
|
+
..."endsWith" in config ? endsWith(config.endsWith) : [],
|
|
483
|
+
..."contains" in config ? contains(config.contains) : []
|
|
484
|
+
];
|
|
485
|
+
const combined = boolLogic === "AND" ? (input) => conditions.every((c) => c(input)) : (input) => conditions.some((c) => c(input));
|
|
486
|
+
return combined;
|
|
487
|
+
};
|
|
488
|
+
var filterFn = (defn, logicCombinator, ifUndefined = "no-impact") => {
|
|
489
|
+
const config = isNotFilter(defn) ? defn["not"] : defn;
|
|
490
|
+
const filter2 = (input) => {
|
|
491
|
+
const undefValue = ifUndefined === "no-impact" ? logicCombinator === "AND" ? true : false : ifUndefined;
|
|
492
|
+
let flag;
|
|
493
|
+
if (typeof input === "undefined") {
|
|
494
|
+
flag = undefValue;
|
|
495
|
+
} else if (isNumericFilter(config)) {
|
|
496
|
+
const fn = numericOps(config, logicCombinator);
|
|
497
|
+
flag = isNotFilter(defn) ? !fn(input) : fn(input);
|
|
498
|
+
} else {
|
|
499
|
+
const fn = stringOps(config, logicCombinator);
|
|
500
|
+
flag = isNotFilter(defn) ? !fn(input) : fn(input);
|
|
501
|
+
}
|
|
502
|
+
return flag;
|
|
503
|
+
};
|
|
504
|
+
return filter2;
|
|
505
|
+
};
|
|
506
|
+
var filter = (config, logicCombinator = "AND", ifUndefined = "no-impact") => {
|
|
507
|
+
return filterFn(config, logicCombinator, ifUndefined);
|
|
508
|
+
};
|
|
509
|
+
|
|
170
510
|
// src/utility/dictionary/arrayToKeyLookup.ts
|
|
171
511
|
function arrayToKeyLookup(...keys2) {
|
|
172
512
|
const obj = {};
|
|
@@ -242,18 +582,6 @@ var dictArr = (...dicts) => {
|
|
|
242
582
|
return api2;
|
|
243
583
|
};
|
|
244
584
|
|
|
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
585
|
// src/utility/dictionary/mapValues.ts
|
|
258
586
|
function mapValues(obj, valueMapper) {
|
|
259
587
|
return Object.fromEntries(
|
|
@@ -262,14 +590,34 @@ function mapValues(obj, valueMapper) {
|
|
|
262
590
|
}
|
|
263
591
|
|
|
264
592
|
// src/utility/dictionary/mapTo.ts
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
593
|
+
var mapper = (config = {}) => (map) => {
|
|
594
|
+
config = {
|
|
595
|
+
input: "req",
|
|
596
|
+
output: "opt",
|
|
597
|
+
direction: "I -> O[]",
|
|
598
|
+
...config
|
|
599
|
+
};
|
|
600
|
+
const fn = (source) => {
|
|
601
|
+
const isArray2 = config.direction === "I -> O[]" && Array.isArray(source) ? true : config.direction === "I[] -> O" && Array.isArray(source) && Array.isArray(source[0]) ? true : false;
|
|
602
|
+
if (isArray2) {
|
|
603
|
+
return source.flatMap(map);
|
|
604
|
+
} else {
|
|
605
|
+
return map(source);
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
return fn;
|
|
272
609
|
};
|
|
610
|
+
var mapToFn = (map) => {
|
|
611
|
+
return mapper()(map);
|
|
612
|
+
};
|
|
613
|
+
var mapToDict = {
|
|
614
|
+
config: (c = { input: "req", output: "opt", direction: "I -> O[]" }) => ({
|
|
615
|
+
map(map) {
|
|
616
|
+
return mapper(c)(map);
|
|
617
|
+
}
|
|
618
|
+
})
|
|
619
|
+
};
|
|
620
|
+
var mapTo = createFnWithProps(mapToFn, mapToDict);
|
|
273
621
|
|
|
274
622
|
// src/utility/dictionary/strArrayToDict.ts
|
|
275
623
|
function strArrayToDict(...strings) {
|
|
@@ -415,33 +763,6 @@ function literal(obj) {
|
|
|
415
763
|
return obj;
|
|
416
764
|
}
|
|
417
765
|
|
|
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
766
|
// src/utility/modelling/Model.ts
|
|
446
767
|
function Model(name) {
|
|
447
768
|
return {
|
|
@@ -459,227 +780,19 @@ function Model(name) {
|
|
|
459
780
|
}
|
|
460
781
|
};
|
|
461
782
|
}
|
|
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
783
|
// Annotate the CommonJS export names for ESM import in node:
|
|
673
784
|
0 && (module.exports = {
|
|
674
785
|
Configurator,
|
|
675
786
|
ExplicitFunction,
|
|
676
787
|
FluentConfigurator,
|
|
788
|
+
MapDirection,
|
|
677
789
|
Model,
|
|
678
790
|
MutationIdentity,
|
|
679
791
|
and,
|
|
680
792
|
api,
|
|
681
793
|
arrayToKeyLookup,
|
|
682
794
|
arrayToObject,
|
|
795
|
+
asArray,
|
|
683
796
|
condition,
|
|
684
797
|
createFnWithProps,
|
|
685
798
|
createMutationFunction,
|
|
@@ -689,10 +802,9 @@ function withValue(td) {
|
|
|
689
802
|
dictToKv,
|
|
690
803
|
dictionaryTransform,
|
|
691
804
|
entries,
|
|
692
|
-
|
|
805
|
+
filter,
|
|
693
806
|
filterDictArray,
|
|
694
807
|
fnWithProps,
|
|
695
|
-
greater,
|
|
696
808
|
groupBy,
|
|
697
809
|
idLiteral,
|
|
698
810
|
idTypeGuard,
|
|
@@ -702,8 +814,10 @@ function withValue(td) {
|
|
|
702
814
|
isBoolean,
|
|
703
815
|
isFalse,
|
|
704
816
|
isFunction,
|
|
817
|
+
isNotFilter,
|
|
705
818
|
isNull,
|
|
706
819
|
isNumber,
|
|
820
|
+
isNumericFilter,
|
|
707
821
|
isObject,
|
|
708
822
|
isString,
|
|
709
823
|
isSymbol,
|
|
@@ -714,11 +828,13 @@ function withValue(td) {
|
|
|
714
828
|
kindLiteral,
|
|
715
829
|
kv,
|
|
716
830
|
kvToDict,
|
|
717
|
-
less,
|
|
718
831
|
literal,
|
|
719
832
|
mapTo,
|
|
833
|
+
mapToDict,
|
|
834
|
+
mapToFn,
|
|
720
835
|
mapValues,
|
|
721
836
|
nameLiteral,
|
|
837
|
+
not,
|
|
722
838
|
or,
|
|
723
839
|
randomString,
|
|
724
840
|
readonlyFnWithProps,
|