inferred-types 0.54.6 → 0.54.7
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/modules/inferred-types/dist/index.cjs +169 -54
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +21238 -20963
- package/modules/inferred-types/dist/index.js +163 -54
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +187 -66
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +4968 -4799
- package/modules/runtime/dist/index.js +181 -66
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.cjs.map +1 -1
- package/modules/types/dist/index.d.ts +8493 -8387
- package/modules/types/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -2506,6 +2506,101 @@ function asApi(api2) {
|
|
|
2506
2506
|
function handleDoneFn(val, call_bare_fn = false) {
|
|
2507
2507
|
return isObject(val) || isFunction(val) ? isDoneFn(val) ? val.done() : isFunction(val) ? call_bare_fn ? val() : val : val : isFunction(val) ? call_bare_fn ? val() : val : val;
|
|
2508
2508
|
}
|
|
2509
|
+
function addPropsToFn(fn2, clone_fn) {
|
|
2510
|
+
const localFn = clone_fn ? (...args) => fn2(args) : fn2;
|
|
2511
|
+
return (obj) => {
|
|
2512
|
+
for (const k in obj) {
|
|
2513
|
+
localFn[k] = obj[k];
|
|
2514
|
+
}
|
|
2515
|
+
return localFn;
|
|
2516
|
+
};
|
|
2517
|
+
}
|
|
2518
|
+
function addFnToProps(props, _clone_fn) {
|
|
2519
|
+
return (fn2) => {
|
|
2520
|
+
const localFn = (...args) => fn2(args);
|
|
2521
|
+
for (const k in props) {
|
|
2522
|
+
localFn[k] = props[k];
|
|
2523
|
+
}
|
|
2524
|
+
return localFn;
|
|
2525
|
+
};
|
|
2526
|
+
}
|
|
2527
|
+
function createCssSelector(_opt) {
|
|
2528
|
+
return (...selectors) => {
|
|
2529
|
+
return selectors.join(" ");
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
function createFnWithProps(fn2, props, narrowing = false) {
|
|
2533
|
+
const fnWithProps = fn2;
|
|
2534
|
+
for (const prop of Object.keys(props)) {
|
|
2535
|
+
fnWithProps[prop] = props[prop];
|
|
2536
|
+
}
|
|
2537
|
+
return isTrue(narrowing) ? fnWithProps : fnWithProps;
|
|
2538
|
+
}
|
|
2539
|
+
function createFnWithPropsExplicit(fn2, props) {
|
|
2540
|
+
const fnWithProps = fn2;
|
|
2541
|
+
for (const prop of Object.keys(props)) {
|
|
2542
|
+
fnWithProps[prop] = props[prop];
|
|
2543
|
+
}
|
|
2544
|
+
return fnWithProps;
|
|
2545
|
+
}
|
|
2546
|
+
function defineObj(literal2 = {}) {
|
|
2547
|
+
return (wide22 = {}) => {
|
|
2548
|
+
const obj = literal2 ? { ...literal2, ...wide22 } : wide22;
|
|
2549
|
+
return obj;
|
|
2550
|
+
};
|
|
2551
|
+
}
|
|
2552
|
+
function defineTuple(...values) {
|
|
2553
|
+
return values.map(
|
|
2554
|
+
(i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i
|
|
2555
|
+
);
|
|
2556
|
+
}
|
|
2557
|
+
function objectToApi(obj, def = null) {
|
|
2558
|
+
const transformed = Object.keys(obj).reduce(
|
|
2559
|
+
(acc, key) => {
|
|
2560
|
+
const val = obj[key];
|
|
2561
|
+
return {
|
|
2562
|
+
...acc,
|
|
2563
|
+
[key]: () => val
|
|
2564
|
+
};
|
|
2565
|
+
},
|
|
2566
|
+
{}
|
|
2567
|
+
);
|
|
2568
|
+
const api2 = {
|
|
2569
|
+
__kind: "ObjectApi",
|
|
2570
|
+
done: () => def,
|
|
2571
|
+
...transformed
|
|
2572
|
+
};
|
|
2573
|
+
return api2;
|
|
2574
|
+
}
|
|
2575
|
+
function mapper() {
|
|
2576
|
+
return (map2) => {
|
|
2577
|
+
return (input) => {
|
|
2578
|
+
const api2 = objectToApi(input);
|
|
2579
|
+
const rtn = map2(api2);
|
|
2580
|
+
return handleDoneFn(rtn);
|
|
2581
|
+
};
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function objectApi() {
|
|
2585
|
+
return {
|
|
2586
|
+
mapTo: (_defn) => ({
|
|
2587
|
+
mapper: mapper()
|
|
2588
|
+
}),
|
|
2589
|
+
mapToWithType: () => mapper()
|
|
2590
|
+
};
|
|
2591
|
+
}
|
|
2592
|
+
function defineObjectApi__Fn(_inputDefn) {
|
|
2593
|
+
return objectApi();
|
|
2594
|
+
}
|
|
2595
|
+
var defineObjectApi__Prop = {
|
|
2596
|
+
withType: () => {
|
|
2597
|
+
return objectApi();
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
var defineObjectApi = createFnWithProps(
|
|
2601
|
+
defineObjectApi__Fn,
|
|
2602
|
+
defineObjectApi__Prop
|
|
2603
|
+
);
|
|
2509
2604
|
function ifArray(val, isAnArray, isNotAnArray) {
|
|
2510
2605
|
return Array.isArray(val) ? isAnArray(val) : isNotAnArray(val);
|
|
2511
2606
|
}
|
|
@@ -4473,6 +4568,31 @@ function keysOf(container) {
|
|
|
4473
4568
|
const keys = Array.isArray(container) ? Object.keys(container).map((i) => Number(i)) : isObject(container) ? isRef(container) ? ["value"] : Object.keys(container) : [];
|
|
4474
4569
|
return keys;
|
|
4475
4570
|
}
|
|
4571
|
+
function callback() {
|
|
4572
|
+
return (cb) => {
|
|
4573
|
+
return (input) => cb(input);
|
|
4574
|
+
};
|
|
4575
|
+
}
|
|
4576
|
+
function narrowFn() {
|
|
4577
|
+
const fn2 = (obj) => obj;
|
|
4578
|
+
return fn2;
|
|
4579
|
+
}
|
|
4580
|
+
function narrowObjectTo(_defn) {
|
|
4581
|
+
return createFnWithPropsExplicit(
|
|
4582
|
+
narrowFn(),
|
|
4583
|
+
{
|
|
4584
|
+
asCallback: callback()
|
|
4585
|
+
}
|
|
4586
|
+
);
|
|
4587
|
+
}
|
|
4588
|
+
function narrowObjectToType() {
|
|
4589
|
+
return createFnWithPropsExplicit(
|
|
4590
|
+
narrowFn(),
|
|
4591
|
+
{
|
|
4592
|
+
asCallback: callback()
|
|
4593
|
+
}
|
|
4594
|
+
);
|
|
4595
|
+
}
|
|
4476
4596
|
function omit(obj, ...removeKeys) {
|
|
4477
4597
|
const keys = Object.keys(obj);
|
|
4478
4598
|
return keys.reduce(
|
|
@@ -4559,75 +4679,27 @@ function fnMeta(func) {
|
|
|
4559
4679
|
};
|
|
4560
4680
|
}
|
|
4561
4681
|
var wrapFn = "NOT IMPLEMENTED";
|
|
4562
|
-
function addPropsToFn(fn2, clone_fn) {
|
|
4563
|
-
const localFn = clone_fn ? (...args) => fn2(args) : fn2;
|
|
4564
|
-
return (obj) => {
|
|
4565
|
-
for (const k in obj) {
|
|
4566
|
-
localFn[k] = obj[k];
|
|
4567
|
-
}
|
|
4568
|
-
return localFn;
|
|
4569
|
-
};
|
|
4570
|
-
}
|
|
4571
|
-
function addFnToProps(props, _clone_fn) {
|
|
4572
|
-
return (fn2) => {
|
|
4573
|
-
const localFn = (...args) => fn2(args);
|
|
4574
|
-
for (const k in props) {
|
|
4575
|
-
localFn[k] = props[k];
|
|
4576
|
-
}
|
|
4577
|
-
return localFn;
|
|
4578
|
-
};
|
|
4579
|
-
}
|
|
4580
|
-
function createCssSelector(_opt) {
|
|
4581
|
-
return (...selectors) => {
|
|
4582
|
-
return selectors.join(" ");
|
|
4583
|
-
};
|
|
4584
|
-
}
|
|
4585
|
-
function createFnWithProps(fn2, props, narrowing = false) {
|
|
4586
|
-
const fnWithProps = fn2;
|
|
4587
|
-
for (const prop of Object.keys(props)) {
|
|
4588
|
-
fnWithProps[prop] = props[prop];
|
|
4589
|
-
}
|
|
4590
|
-
return isTrue(narrowing) ? fnWithProps : fnWithProps;
|
|
4591
|
-
}
|
|
4592
|
-
function createFnWithPropsExplicit(fn2, props) {
|
|
4593
|
-
const fnWithProps = fn2;
|
|
4594
|
-
for (const prop of Object.keys(props)) {
|
|
4595
|
-
fnWithProps[prop] = props[prop];
|
|
4596
|
-
}
|
|
4597
|
-
return fnWithProps;
|
|
4598
|
-
}
|
|
4599
|
-
function defineObj(literal2 = {}) {
|
|
4600
|
-
return (wide22 = {}) => {
|
|
4601
|
-
const obj = literal2 ? { ...literal2, ...wide22 } : wide22;
|
|
4602
|
-
return obj;
|
|
4603
|
-
};
|
|
4604
|
-
}
|
|
4605
|
-
function defineTuple(...values) {
|
|
4606
|
-
return values.map(
|
|
4607
|
-
(i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i
|
|
4608
|
-
);
|
|
4609
|
-
}
|
|
4610
4682
|
function asArray(thing) {
|
|
4611
4683
|
return Array.isArray(thing) === true ? thing : typeof thing === "undefined" ? [] : [thing];
|
|
4612
4684
|
}
|
|
4613
|
-
function createConverter(
|
|
4685
|
+
function createConverter(mapper2) {
|
|
4614
4686
|
return (input) => {
|
|
4615
4687
|
let result2;
|
|
4616
4688
|
if (isNothing(input)) {
|
|
4617
|
-
result2 =
|
|
4689
|
+
result2 = mapper2.nothing ? mapper2.nothing(input) : Never2;
|
|
4618
4690
|
} else if (isObject(input)) {
|
|
4619
|
-
result2 =
|
|
4691
|
+
result2 = mapper2.object ? mapper2.object(input) : Never2;
|
|
4620
4692
|
} else {
|
|
4621
4693
|
switch (typeof input) {
|
|
4622
4694
|
case "string":
|
|
4623
|
-
result2 =
|
|
4695
|
+
result2 = mapper2.string ? mapper2.string(input) : Never2;
|
|
4624
4696
|
break;
|
|
4625
4697
|
case "number":
|
|
4626
4698
|
case "bigint":
|
|
4627
|
-
result2 =
|
|
4699
|
+
result2 = mapper2.number ? mapper2.number(input) : Never2;
|
|
4628
4700
|
break;
|
|
4629
4701
|
case "boolean":
|
|
4630
|
-
result2 =
|
|
4702
|
+
result2 = mapper2.boolean ? mapper2.boolean(input) : Never2;
|
|
4631
4703
|
break;
|
|
4632
4704
|
default:
|
|
4633
4705
|
throw new Error(`Unhandled type: ${typeof input}`);
|
|
@@ -5147,6 +5219,37 @@ function lookupCountryCode(token) {
|
|
|
5147
5219
|
const uc = uppercase(token);
|
|
5148
5220
|
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
5149
5221
|
}
|
|
5222
|
+
function asMapper(fn2) {
|
|
5223
|
+
const props = {
|
|
5224
|
+
kind: "Mapper",
|
|
5225
|
+
map: (from) => {
|
|
5226
|
+
return from.map(fn2);
|
|
5227
|
+
}
|
|
5228
|
+
};
|
|
5229
|
+
return createFnWithPropsExplicit(fn2, props);
|
|
5230
|
+
}
|
|
5231
|
+
function createObjectMap() {
|
|
5232
|
+
return (map2) => {
|
|
5233
|
+
const fn2 = (input) => {
|
|
5234
|
+
return Object.keys(map2).reduce(
|
|
5235
|
+
(acc, key) => {
|
|
5236
|
+
const val = map2[key];
|
|
5237
|
+
return {
|
|
5238
|
+
...acc,
|
|
5239
|
+
[key]: isFunction(val) ? val(input) : val
|
|
5240
|
+
};
|
|
5241
|
+
},
|
|
5242
|
+
{}
|
|
5243
|
+
);
|
|
5244
|
+
};
|
|
5245
|
+
return fn2;
|
|
5246
|
+
};
|
|
5247
|
+
}
|
|
5248
|
+
function createMapper() {
|
|
5249
|
+
return (fn2) => {
|
|
5250
|
+
return asMapper(fn2);
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5150
5253
|
function mergeObjects(defVal, override) {
|
|
5151
5254
|
const intersectingKeys = sharedKeys(defVal, override);
|
|
5152
5255
|
const defUnique = withoutKeys(defVal, ...intersectingKeys);
|
|
@@ -7194,12 +7297,15 @@ export {
|
|
|
7194
7297
|
createFnWithProps,
|
|
7195
7298
|
createFnWithPropsExplicit,
|
|
7196
7299
|
createLifoQueue,
|
|
7300
|
+
createMapper,
|
|
7301
|
+
createObjectMap,
|
|
7197
7302
|
createTypeToken,
|
|
7198
7303
|
cssColor,
|
|
7199
7304
|
csv,
|
|
7200
7305
|
defineCss,
|
|
7201
7306
|
defineObj,
|
|
7202
7307
|
defineObject,
|
|
7308
|
+
defineObjectApi,
|
|
7203
7309
|
defineTuple,
|
|
7204
7310
|
endsWith,
|
|
7205
7311
|
ensureLeading,
|
|
@@ -7518,7 +7624,10 @@ export {
|
|
|
7518
7624
|
mergeTuples,
|
|
7519
7625
|
nameLiteral,
|
|
7520
7626
|
narrow,
|
|
7627
|
+
narrowObjectTo,
|
|
7628
|
+
narrowObjectToType,
|
|
7521
7629
|
never,
|
|
7630
|
+
objectToApi,
|
|
7522
7631
|
omit,
|
|
7523
7632
|
optional,
|
|
7524
7633
|
optionalOrNull,
|