inferred-types 0.18.0 → 0.18.4
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 +41 -35
- package/dist/index.js +50 -28
- package/dist/index.mjs +37 -16
- package/on-hold/Builder/index.ts +15 -21
- package/on-hold/types/index.ts +15 -20
- package/package.json +17 -21
- package/pnpm-lock.yaml +1264 -2929
- package/src/Mutation/index.ts +16 -18
- package/src/index.ts +15 -19
- package/src/shared/index.ts +16 -18
- package/src/types/Where.ts +19 -15
- package/src/types/alphabetic/index.ts +10 -18
- package/src/types/dictionary/index.ts +16 -18
- package/src/types/fluent/index.ts +10 -17
- package/src/types/index.ts +10 -19
- package/src/types/kv/index.ts +16 -18
- package/src/types/lists/index.ts +16 -18
- package/src/types/string-literals/index.ts +16 -18
- package/src/types/tuples/index.ts +16 -18
- package/src/types/type-conversion/index.ts +10 -17
- package/src/utility/api/index.ts +16 -18
- package/src/utility/dictionary/index.ts +16 -21
- package/src/utility/dictionary/kv/index.ts +16 -18
- package/src/utility/index.ts +16 -20
- package/src/utility/lists/index.ts +16 -18
- package/src/utility/literals/index.ts +16 -18
- package/src/utility/map-reduce/index.ts +16 -18
- package/src/utility/modelling/index.ts +16 -18
- package/src/utility/runtime/conditions/index.ts +16 -18
- package/src/utility/runtime/ifTypeOf.ts +1 -5
- package/src/utility/runtime/index.ts +16 -20
- package/src/utility/state/Configurator.ts +12 -3
- package/src/utility/state/index.ts +16 -18
- package/tests/data/index.ts +9 -14
- package/tests/kv/dict-to-kv-and-back.spec.ts +24 -18
- package/.tsbuildinfo +0 -1
- package/src/errors/InferenceError.ts +0 -3
- package/src/errors/index.ts +0 -37
- package/src/utility/dictionary/dictFilter.ts +0 -19
- package/tests/kv/dictFilter.ts +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import * as inferred_types from 'inferred-types';
|
|
2
|
-
import * as brilliant_errors_dist_typings from 'brilliant-errors/dist/typings';
|
|
3
|
-
import { Include as Include$1 } from 'native-dash';
|
|
4
1
|
import { Alpha as Alpha$1 } from 'common-types';
|
|
5
2
|
|
|
6
3
|
/**
|
|
@@ -50,8 +47,42 @@ declare type MutationFunction<T extends any, P extends any[]> = (...args: P) =>
|
|
|
50
47
|
*/
|
|
51
48
|
declare function createMutationFunction<T extends any>(state: T): <M extends MutationIdentity<T, P>, P extends any[]>(mutationIdentity: M) => (...args: P) => T;
|
|
52
49
|
|
|
53
|
-
declare
|
|
54
|
-
|
|
50
|
+
declare function randomString(): string;
|
|
51
|
+
|
|
52
|
+
declare function uuid(): string;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* A union of types used in conjunction with the `literalValues()` function
|
|
56
|
+
* to produce a _narrow_ type definition of a passed in dictionary object.
|
|
57
|
+
*/
|
|
58
|
+
declare type Narrowable = string | number | boolean | symbol | object | undefined | void | null | {};
|
|
59
|
+
|
|
60
|
+
declare type ValueTuple = [type: any, narrowable: boolean];
|
|
61
|
+
/**
|
|
62
|
+
* An API surface for choosing a **type** which is defined for run-time
|
|
63
|
+
* use but is translatable to the type system as well.
|
|
64
|
+
*/
|
|
65
|
+
declare type ValueTypes = {
|
|
66
|
+
string: [string, false];
|
|
67
|
+
boolean: [];
|
|
68
|
+
};
|
|
69
|
+
declare const valueTypes: {
|
|
70
|
+
string: [string, false];
|
|
71
|
+
boolean: [boolean, false];
|
|
72
|
+
number: [number, false];
|
|
73
|
+
function: [Function, false];
|
|
74
|
+
object: [Record<string, any>, false];
|
|
75
|
+
array: <T extends unknown>(arr?: T[]) => [T[], false];
|
|
76
|
+
null: [null, false];
|
|
77
|
+
symbol: [Symbol, false];
|
|
78
|
+
undefined: [undefined, false];
|
|
79
|
+
true: [true, true];
|
|
80
|
+
false: [false, true];
|
|
81
|
+
/** pass in a literal type */
|
|
82
|
+
literal: <N extends Narrowable, T_1 extends string | number | boolean | symbol | Record<any, N> | null | undefined>(v: T_1) => [T_1, true];
|
|
83
|
+
literalArray: <N_1 extends Narrowable, T_2 extends string | number | boolean | symbol | Record<any, N_1> | null | undefined>(arr: T_2[]) => (boolean | T_2[])[];
|
|
84
|
+
};
|
|
85
|
+
declare type ValueTypeFunc<N extends Narrowable, T extends Record<any, N> | number | string | boolean | symbol | null | Function> = (v: ValueTypes) => [T, boolean];
|
|
55
86
|
|
|
56
87
|
declare type ApiFunction<P extends any[], R extends any> = (...args: P) => R;
|
|
57
88
|
declare type FluentFunction<P extends any[], R extends any> = (...args: P) => R;
|
|
@@ -195,12 +226,6 @@ declare type Mutable<T> = {
|
|
|
195
226
|
-readonly [K in keyof T]: T[K];
|
|
196
227
|
};
|
|
197
228
|
|
|
198
|
-
/**
|
|
199
|
-
* A union of types used in conjunction with the `literalValues()` function
|
|
200
|
-
* to produce a _narrow_ type definition of a passed in dictionary object.
|
|
201
|
-
*/
|
|
202
|
-
declare type Narrowable = string | number | boolean | symbol | object | undefined | void | null | {};
|
|
203
|
-
|
|
204
229
|
/**
|
|
205
230
|
* Provides a negation of a type of the type `T` _not_ `U`.
|
|
206
231
|
* ```ts
|
|
@@ -300,7 +325,7 @@ declare type TypeGuard<T> = (thing: unknown) => thing is T;
|
|
|
300
325
|
* type BA = Where<typeof arr, `ba${string}`>;
|
|
301
326
|
* ```
|
|
302
327
|
*/
|
|
303
|
-
declare type Where<T extends Record<string, any> | readonly string[], U> = T extends readonly string[] ? Include
|
|
328
|
+
declare type Where<T extends Record<string, any> | readonly string[], U> = T extends readonly string[] ? Include<T[number], U> : {
|
|
304
329
|
[K in keyof T]: K extends U ? K : never;
|
|
305
330
|
}[keyof T];
|
|
306
331
|
/**
|
|
@@ -579,19 +604,6 @@ declare type AllCaps<T extends string> = string extends T ? "unknown" : T extend
|
|
|
579
604
|
|
|
580
605
|
declare type CamelCase<S extends string> = Uncapitalize<PascalCase<S>>;
|
|
581
606
|
|
|
582
|
-
/**
|
|
583
|
-
* Strips the non-alpha characters that lead a string
|
|
584
|
-
*/
|
|
585
|
-
declare type StripLeftNonAlpha<S extends string> = S extends `${infer First}${infer Rest}` ? First extends NonAlpha ? StripLeftNonAlpha<Rest> : S : never;
|
|
586
|
-
/**
|
|
587
|
-
* identifies the leading characters which are _not_ alphabetical
|
|
588
|
-
*/
|
|
589
|
-
declare type LeadingNonAlpha<S extends string> = Replace<S, StripLeftNonAlpha<S>, "">;
|
|
590
|
-
/**
|
|
591
|
-
* Capitalize the first alphabetical character in the string
|
|
592
|
-
*/
|
|
593
|
-
declare type CapFirstAlpha<T extends string> = LeadingNonAlpha<T> extends string ? `${LeadingNonAlpha<T>}${Capitalize<Replace<T, LeadingNonAlpha<T>, "">>}` : Capitalize<T>;
|
|
594
|
-
|
|
595
607
|
/**
|
|
596
608
|
* Capitalize all words in a string
|
|
597
609
|
*/
|
|
@@ -1120,14 +1132,6 @@ declare const api: <N extends Narrowable, TPrivate extends Readonly<Record<any,
|
|
|
1120
1132
|
*/
|
|
1121
1133
|
declare function arrayToKeyLookup<T extends readonly string[]>(...keys: T): Record<T[number], true>;
|
|
1122
1134
|
|
|
1123
|
-
declare type ObjFilterCallback<T extends object, R extends boolean> = (k: keyof T, state: T) => R;
|
|
1124
|
-
/**
|
|
1125
|
-
* **dictFilter**
|
|
1126
|
-
*
|
|
1127
|
-
* Provides a means ot filter down the properties on a given object.
|
|
1128
|
-
*/
|
|
1129
|
-
declare function dictFilter<N extends Narrowable, T extends Record<string, N>, R extends boolean>(obj: T, cb: ObjFilterCallback<T, R>): Exclude<T, (keyof T)[]>;
|
|
1130
|
-
|
|
1131
1135
|
/**
|
|
1132
1136
|
* Takes a dictionary of type `I` and converts it to a dictionary of type `O` where
|
|
1133
1137
|
* they _keys_ used in both dictionaries are the same.
|
|
@@ -1505,11 +1509,13 @@ declare function type<T extends any, V extends Function>(fn: TypeDefinition<T, V
|
|
|
1505
1509
|
*/
|
|
1506
1510
|
declare function withValue<T extends any, V extends Function>(td: TypeDefinition<T, V>): <N extends Narrowable, R extends Record<string, N>>(obj: R) => ExpandRecursively<Pick<R, KeysWithValue<T, R>>>;
|
|
1507
1511
|
|
|
1512
|
+
declare type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
1513
|
+
|
|
1508
1514
|
interface IConfigurator<C = {}> {
|
|
1509
1515
|
set<V, K extends string, KV = {
|
|
1510
1516
|
[U in K]: V;
|
|
1511
1517
|
}>(key: K, value: V): asserts this is IConfigurator<ExpandRecursively<C & KV>>;
|
|
1512
|
-
remove<K extends string & keyof C>(key: K): asserts this is IConfigurator<ExpandRecursively<Omit<C, K>>>;
|
|
1518
|
+
remove<K extends string & keyof C>(key: K): asserts this is IConfigurator<ExpandRecursively<Omit$1<C, K>>>;
|
|
1513
1519
|
done(): C;
|
|
1514
1520
|
}
|
|
1515
1521
|
/**
|
|
@@ -9764,4 +9770,4 @@ declare function KeyStorage(): {
|
|
|
9764
9770
|
done: () => never[];
|
|
9765
9771
|
};
|
|
9766
9772
|
|
|
9767
|
-
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AssertExtends, Bracket, Break, CamelCase,
|
|
9773
|
+
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, ClosingBracket, Condition, Configurator, Constructor, DashToSnake, DashUppercase, Dasherize, DictArray, DictArrayFilterCallback, DictArrayKv, DictFromKv, DictKvTuple, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, Filter, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsObject, IsString, IsTrue, KebabCase, KeyStorage, KeyStorageApi, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LowerAllCaps, LowerAlpha, MaybeFalse, MaybeTrue, Model, Mutable, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, Numeric, NumericKeys, NumericString, ObjectType, Opaque, OpenningBracket, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SnakeCase, SpecialCharacters, StringDelimiter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefinition, TypeGuard, TypeOptions, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, WithNumericKeys, WithStringKeys, WithValue, WrapValue, ZipCode, and, api, arrayToKeyLookup, arrayToObject, condition, createFnWithProps, createMutationFunction, defineType, dictToKv, dictionaryTransform, entries, equals, filterDictArray, greater, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isLiteral, isNull, isNumber, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, less, literal, mapValues, nameLiteral, or, randomString, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, valuesOfProp, withValue };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -23,28 +21,29 @@ var __spreadValues = (a, b) => {
|
|
|
23
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
22
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
23
|
var __export = (target, all) => {
|
|
26
|
-
__markAsModule(target);
|
|
27
24
|
for (var name in all)
|
|
28
25
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
29
26
|
};
|
|
30
|
-
var __reExport = (target, module2, desc) => {
|
|
27
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
31
28
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
32
29
|
for (let key of __getOwnPropNames(module2))
|
|
33
|
-
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
30
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
34
31
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
35
32
|
}
|
|
36
33
|
return target;
|
|
37
34
|
};
|
|
38
|
-
var
|
|
39
|
-
return
|
|
40
|
-
};
|
|
35
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
36
|
+
return (module2, temp) => {
|
|
37
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
38
|
+
};
|
|
39
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
41
40
|
|
|
42
41
|
// src/index.ts
|
|
43
|
-
|
|
42
|
+
var src_exports = {};
|
|
43
|
+
__export(src_exports, {
|
|
44
44
|
Configurator: () => Configurator,
|
|
45
45
|
ExplicitFunction: () => ExplicitFunction,
|
|
46
46
|
FluentConfigurator: () => FluentConfigurator,
|
|
47
|
-
InferenceError: () => InferenceError,
|
|
48
47
|
KeyStorage: () => KeyStorage,
|
|
49
48
|
Model: () => Model,
|
|
50
49
|
MutationIdentity: () => MutationIdentity,
|
|
@@ -56,7 +55,6 @@ __export(exports, {
|
|
|
56
55
|
createFnWithProps: () => createFnWithProps,
|
|
57
56
|
createMutationFunction: () => createMutationFunction,
|
|
58
57
|
defineType: () => defineType,
|
|
59
|
-
dictFilter: () => dictFilter,
|
|
60
58
|
dictToKv: () => dictToKv,
|
|
61
59
|
dictionaryTransform: () => dictionaryTransform,
|
|
62
60
|
entries: () => entries,
|
|
@@ -72,7 +70,6 @@ __export(exports, {
|
|
|
72
70
|
isBoolean: () => isBoolean,
|
|
73
71
|
isFalse: () => isFalse,
|
|
74
72
|
isFunction: () => isFunction,
|
|
75
|
-
isInferenceError: () => isInferenceError,
|
|
76
73
|
isLiteral: () => isLiteral,
|
|
77
74
|
isNull: () => isNull,
|
|
78
75
|
isNumber: () => isNumber,
|
|
@@ -91,10 +88,13 @@ __export(exports, {
|
|
|
91
88
|
mapValues: () => mapValues,
|
|
92
89
|
nameLiteral: () => nameLiteral,
|
|
93
90
|
or: () => or,
|
|
91
|
+
randomString: () => randomString,
|
|
94
92
|
ruleSet: () => ruleSet,
|
|
95
93
|
strArrayToDict: () => strArrayToDict,
|
|
96
94
|
type: () => type,
|
|
97
95
|
typeApi: () => typeApi,
|
|
96
|
+
uuid: () => uuid,
|
|
97
|
+
valueTypes: () => valueTypes,
|
|
98
98
|
valuesOfProp: () => valuesOfProp,
|
|
99
99
|
withValue: () => withValue
|
|
100
100
|
});
|
|
@@ -113,9 +113,34 @@ function MutationIdentity() {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
// src/
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
// src/shared/randomString.ts
|
|
117
|
+
function randomString() {
|
|
118
|
+
return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// src/shared/uuid.ts
|
|
122
|
+
function uuid() {
|
|
123
|
+
return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/shared/valueTypes.ts
|
|
127
|
+
var valueTypes = {
|
|
128
|
+
string: ["", false],
|
|
129
|
+
boolean: [true, false],
|
|
130
|
+
number: [0, false],
|
|
131
|
+
function: [() => "", false],
|
|
132
|
+
object: [{}, false],
|
|
133
|
+
array: (arr = []) => [arr, false],
|
|
134
|
+
null: [null, false],
|
|
135
|
+
symbol: [Symbol("type"), false],
|
|
136
|
+
undefined: [void 0, false],
|
|
137
|
+
true: [true, true],
|
|
138
|
+
false: [false, true],
|
|
139
|
+
literal: (v) => {
|
|
140
|
+
return [v, true];
|
|
141
|
+
},
|
|
142
|
+
literalArray: (arr) => [arr, true]
|
|
143
|
+
};
|
|
119
144
|
|
|
120
145
|
// src/utility/keys.ts
|
|
121
146
|
function keys(obj, ...without) {
|
|
@@ -155,13 +180,6 @@ function arrayToKeyLookup(...keys2) {
|
|
|
155
180
|
return obj;
|
|
156
181
|
}
|
|
157
182
|
|
|
158
|
-
// src/utility/dictionary/dictFilter.ts
|
|
159
|
-
var import_native_dash = __toModule(require("native-dash"));
|
|
160
|
-
function dictFilter(obj, cb) {
|
|
161
|
-
const remove = keys(obj).filter((k) => !cb(k, obj));
|
|
162
|
-
return (0, import_native_dash.omit)(obj, ...keys(obj).filter((k) => !cb(k, obj)));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
183
|
// src/utility/dictionary/dictionaryTransform.ts
|
|
166
184
|
function dictionaryTransform(input, transform) {
|
|
167
185
|
return keys(input).reduce((acc, i) => {
|
|
@@ -207,7 +225,10 @@ function dictToKv(obj, _makeTuple = false) {
|
|
|
207
225
|
}
|
|
208
226
|
|
|
209
227
|
// src/utility/state/Configurator.ts
|
|
210
|
-
|
|
228
|
+
function omit(obj, ...removals) {
|
|
229
|
+
const untyped = removals;
|
|
230
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
231
|
+
}
|
|
211
232
|
function Configurator() {
|
|
212
233
|
let configuration = () => ({});
|
|
213
234
|
const api2 = () => {
|
|
@@ -221,7 +242,7 @@ function Configurator() {
|
|
|
221
242
|
},
|
|
222
243
|
remove(key) {
|
|
223
244
|
const config = configuration();
|
|
224
|
-
const updated =
|
|
245
|
+
const updated = omit(config, key);
|
|
225
246
|
configuration = () => updated;
|
|
226
247
|
return updated;
|
|
227
248
|
},
|
|
@@ -410,7 +431,7 @@ function runtimeExtendsCheck(val, base, narrow = false) {
|
|
|
410
431
|
return true;
|
|
411
432
|
case "function":
|
|
412
433
|
if (narrow) {
|
|
413
|
-
throw new
|
|
434
|
+
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
414
435
|
}
|
|
415
436
|
return true;
|
|
416
437
|
case "object":
|
|
@@ -598,12 +619,12 @@ function withValue(td) {
|
|
|
598
619
|
}));
|
|
599
620
|
};
|
|
600
621
|
}
|
|
622
|
+
module.exports = __toCommonJS(src_exports);
|
|
601
623
|
// Annotate the CommonJS export names for ESM import in node:
|
|
602
624
|
0 && (module.exports = {
|
|
603
625
|
Configurator,
|
|
604
626
|
ExplicitFunction,
|
|
605
627
|
FluentConfigurator,
|
|
606
|
-
InferenceError,
|
|
607
628
|
KeyStorage,
|
|
608
629
|
Model,
|
|
609
630
|
MutationIdentity,
|
|
@@ -615,7 +636,6 @@ function withValue(td) {
|
|
|
615
636
|
createFnWithProps,
|
|
616
637
|
createMutationFunction,
|
|
617
638
|
defineType,
|
|
618
|
-
dictFilter,
|
|
619
639
|
dictToKv,
|
|
620
640
|
dictionaryTransform,
|
|
621
641
|
entries,
|
|
@@ -631,7 +651,6 @@ function withValue(td) {
|
|
|
631
651
|
isBoolean,
|
|
632
652
|
isFalse,
|
|
633
653
|
isFunction,
|
|
634
|
-
isInferenceError,
|
|
635
654
|
isLiteral,
|
|
636
655
|
isNull,
|
|
637
656
|
isNumber,
|
|
@@ -650,10 +669,13 @@ function withValue(td) {
|
|
|
650
669
|
mapValues,
|
|
651
670
|
nameLiteral,
|
|
652
671
|
or,
|
|
672
|
+
randomString,
|
|
653
673
|
ruleSet,
|
|
654
674
|
strArrayToDict,
|
|
655
675
|
type,
|
|
656
676
|
typeApi,
|
|
677
|
+
uuid,
|
|
678
|
+
valueTypes,
|
|
657
679
|
valuesOfProp,
|
|
658
680
|
withValue
|
|
659
681
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -32,9 +32,34 @@ function MutationIdentity() {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
// src/
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
// src/shared/randomString.ts
|
|
36
|
+
function randomString() {
|
|
37
|
+
return Math.trunc((1 + Math.random()) * 65536).toString(16).slice(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/shared/uuid.ts
|
|
41
|
+
function uuid() {
|
|
42
|
+
return `${randomString()}${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}-${randomString()}${randomString()}${randomString()}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/shared/valueTypes.ts
|
|
46
|
+
var valueTypes = {
|
|
47
|
+
string: ["", false],
|
|
48
|
+
boolean: [true, false],
|
|
49
|
+
number: [0, false],
|
|
50
|
+
function: [() => "", false],
|
|
51
|
+
object: [{}, false],
|
|
52
|
+
array: (arr = []) => [arr, false],
|
|
53
|
+
null: [null, false],
|
|
54
|
+
symbol: [Symbol("type"), false],
|
|
55
|
+
undefined: [void 0, false],
|
|
56
|
+
true: [true, true],
|
|
57
|
+
false: [false, true],
|
|
58
|
+
literal: (v) => {
|
|
59
|
+
return [v, true];
|
|
60
|
+
},
|
|
61
|
+
literalArray: (arr) => [arr, true]
|
|
62
|
+
};
|
|
38
63
|
|
|
39
64
|
// src/utility/keys.ts
|
|
40
65
|
function keys(obj, ...without) {
|
|
@@ -74,13 +99,6 @@ function arrayToKeyLookup(...keys2) {
|
|
|
74
99
|
return obj;
|
|
75
100
|
}
|
|
76
101
|
|
|
77
|
-
// src/utility/dictionary/dictFilter.ts
|
|
78
|
-
import { omit } from "native-dash";
|
|
79
|
-
function dictFilter(obj, cb) {
|
|
80
|
-
const remove = keys(obj).filter((k) => !cb(k, obj));
|
|
81
|
-
return omit(obj, ...keys(obj).filter((k) => !cb(k, obj)));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
102
|
// src/utility/dictionary/dictionaryTransform.ts
|
|
85
103
|
function dictionaryTransform(input, transform) {
|
|
86
104
|
return keys(input).reduce((acc, i) => {
|
|
@@ -126,7 +144,10 @@ function dictToKv(obj, _makeTuple = false) {
|
|
|
126
144
|
}
|
|
127
145
|
|
|
128
146
|
// src/utility/state/Configurator.ts
|
|
129
|
-
|
|
147
|
+
function omit(obj, ...removals) {
|
|
148
|
+
const untyped = removals;
|
|
149
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
150
|
+
}
|
|
130
151
|
function Configurator() {
|
|
131
152
|
let configuration = () => ({});
|
|
132
153
|
const api2 = () => {
|
|
@@ -140,7 +161,7 @@ function Configurator() {
|
|
|
140
161
|
},
|
|
141
162
|
remove(key) {
|
|
142
163
|
const config = configuration();
|
|
143
|
-
const updated =
|
|
164
|
+
const updated = omit(config, key);
|
|
144
165
|
configuration = () => updated;
|
|
145
166
|
return updated;
|
|
146
167
|
},
|
|
@@ -329,7 +350,7 @@ function runtimeExtendsCheck(val, base, narrow = false) {
|
|
|
329
350
|
return true;
|
|
330
351
|
case "function":
|
|
331
352
|
if (narrow) {
|
|
332
|
-
throw new
|
|
353
|
+
throw new Error(`Use of narrowlyExtends with a function is not possible!`);
|
|
333
354
|
}
|
|
334
355
|
return true;
|
|
335
356
|
case "object":
|
|
@@ -521,7 +542,6 @@ export {
|
|
|
521
542
|
Configurator,
|
|
522
543
|
ExplicitFunction,
|
|
523
544
|
FluentConfigurator,
|
|
524
|
-
InferenceError,
|
|
525
545
|
KeyStorage,
|
|
526
546
|
Model,
|
|
527
547
|
MutationIdentity,
|
|
@@ -533,7 +553,6 @@ export {
|
|
|
533
553
|
createFnWithProps,
|
|
534
554
|
createMutationFunction,
|
|
535
555
|
defineType,
|
|
536
|
-
dictFilter,
|
|
537
556
|
dictToKv,
|
|
538
557
|
dictionaryTransform,
|
|
539
558
|
entries,
|
|
@@ -549,7 +568,6 @@ export {
|
|
|
549
568
|
isBoolean,
|
|
550
569
|
isFalse,
|
|
551
570
|
isFunction,
|
|
552
|
-
isInferenceError,
|
|
553
571
|
isLiteral,
|
|
554
572
|
isNull,
|
|
555
573
|
isNumber,
|
|
@@ -568,10 +586,13 @@ export {
|
|
|
568
586
|
mapValues,
|
|
569
587
|
nameLiteral,
|
|
570
588
|
or,
|
|
589
|
+
randomString,
|
|
571
590
|
ruleSet,
|
|
572
591
|
strArrayToDict,
|
|
573
592
|
type,
|
|
574
593
|
typeApi,
|
|
594
|
+
uuid,
|
|
595
|
+
valueTypes,
|
|
575
596
|
valuesOfProp,
|
|
576
597
|
withValue
|
|
577
598
|
};
|
package/on-hold/Builder/index.ts
CHANGED
|
@@ -1,41 +1,35 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: da242834
|
|
4
6
|
|
|
5
|
-
// index last changed at: 5th May, 2021, 07:16 AM ( GMT-7 )
|
|
6
|
-
// export: named; exclusions: index, private.
|
|
7
|
-
// files: Builder, BuilderApi, IdentityToMutationApi, MutationToFluentApi.
|
|
8
7
|
|
|
9
|
-
// local file exports
|
|
10
|
-
export * from "./Builder";
|
|
11
|
-
export * from "./BuilderApi";
|
|
12
|
-
export * from "./IdentityToMutationApi";
|
|
13
|
-
export * from "./MutationToFluentApi";
|
|
14
8
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
// This file was created by running: "dd
|
|
18
|
-
// the 'do-devops' pkg installed as a dev dep.
|
|
9
|
+
// #endregion
|
|
10
|
+
|
|
11
|
+
// This file was created by running: "dd autoindex"; it assumes you have
|
|
12
|
+
// the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
|
|
19
13
|
//
|
|
20
14
|
// By default it assumes that exports are named exports but this can be changed by
|
|
21
15
|
// adding a modifier to the '// #autoindex' syntax:
|
|
22
16
|
//
|
|
23
17
|
// - autoindex:named same as default, exports "named symbols"
|
|
24
|
-
// - autoindex:default assumes each file is exporting a default export
|
|
25
|
-
//
|
|
26
|
-
// file
|
|
18
|
+
// - autoindex:default assumes each file is exporting a default export and
|
|
19
|
+
// converts the default export to the name of the file
|
|
27
20
|
// - autoindex:offset assumes files export "named symbols" but that each
|
|
28
21
|
// file's symbols should be offset by the file's name
|
|
29
|
-
// (useful for files which might symbols which collide
|
|
30
|
-
// or where the namespacing helps consumers)
|
|
31
22
|
//
|
|
32
23
|
// You may also exclude certain files or directories by adding it to the
|
|
33
24
|
// autoindex command. As an example:
|
|
34
25
|
//
|
|
35
26
|
// - autoindex:named, exclude: foo,bar,baz
|
|
36
27
|
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
28
|
+
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
29
|
+
// below this file will not reference this autoindex file:
|
|
30
|
+
//
|
|
31
|
+
// - autoindex:named, orphan
|
|
32
|
+
//
|
|
33
|
+
// All content outside the "// #region" section in this file will be
|
|
34
|
+
// preserved in situations where you need to do something paricularly awesome.
|
|
39
35
|
// Keep on being awesome.
|
|
40
|
-
|
|
41
|
-
// #endregion
|
package/on-hold/types/index.ts
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: da242834
|
|
3
5
|
|
|
4
|
-
// index last changed at: 8th Aug, 2021, 10:48 AM ( GMT-7 )
|
|
5
|
-
// export: named; exclusions: index, private.
|
|
6
|
-
// files: object, prop, scalar.
|
|
7
6
|
|
|
8
|
-
// local file exports
|
|
9
|
-
export * from "./object";
|
|
10
|
-
export * from "./prop";
|
|
11
|
-
export * from "./scalar";
|
|
12
7
|
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
// This file was created by running: "dd
|
|
16
|
-
// the 'do-devops' pkg installed as a dev dep.
|
|
8
|
+
// #endregion
|
|
9
|
+
|
|
10
|
+
// This file was created by running: "dd autoindex"; it assumes you have
|
|
11
|
+
// the 'do-devops' pkg (that's "dd" on npm) installed as a dev dep.
|
|
17
12
|
//
|
|
18
13
|
// By default it assumes that exports are named exports but this can be changed by
|
|
19
14
|
// adding a modifier to the '// #autoindex' syntax:
|
|
20
15
|
//
|
|
21
16
|
// - autoindex:named same as default, exports "named symbols"
|
|
22
|
-
// - autoindex:default assumes each file is exporting a default export
|
|
23
|
-
//
|
|
24
|
-
// file
|
|
17
|
+
// - autoindex:default assumes each file is exporting a default export and
|
|
18
|
+
// converts the default export to the name of the file
|
|
25
19
|
// - autoindex:offset assumes files export "named symbols" but that each
|
|
26
20
|
// file's symbols should be offset by the file's name
|
|
27
|
-
// (useful for files which might symbols which collide
|
|
28
|
-
// or where the namespacing helps consumers)
|
|
29
21
|
//
|
|
30
22
|
// You may also exclude certain files or directories by adding it to the
|
|
31
23
|
// autoindex command. As an example:
|
|
32
24
|
//
|
|
33
25
|
// - autoindex:named, exclude: foo,bar,baz
|
|
34
26
|
//
|
|
35
|
-
//
|
|
36
|
-
//
|
|
27
|
+
// Inversely, if you state a file to be an "orphan" then autoindex files
|
|
28
|
+
// below this file will not reference this autoindex file:
|
|
29
|
+
//
|
|
30
|
+
// - autoindex:named, orphan
|
|
31
|
+
//
|
|
32
|
+
// All content outside the "// #region" section in this file will be
|
|
33
|
+
// preserved in situations where you need to do something paricularly awesome.
|
|
37
34
|
// Keep on being awesome.
|
|
38
|
-
|
|
39
|
-
// #endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inferred-types",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.4",
|
|
4
4
|
"description": "Functions which provide useful type inference on TS projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ken Snyder<ken@ken.net>",
|
|
@@ -20,36 +20,32 @@
|
|
|
20
20
|
"test": "jest"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@antfu/eslint-config-ts": "^0.11.0",
|
|
24
23
|
"@type-challenges/utils": "~0.1.1",
|
|
25
|
-
"@types/jest": "^27.0
|
|
26
|
-
"@types/node": "^14.
|
|
27
|
-
"@typescript-eslint/eslint-plugin": "^5.1
|
|
28
|
-
"@typescript-eslint/parser": "^5.1
|
|
24
|
+
"@types/jest": "^27.4.0",
|
|
25
|
+
"@types/node": "^14.18.5",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
27
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
29
28
|
"common-types": "^1.30.0",
|
|
30
29
|
"cross-env": "^7.0.3",
|
|
31
|
-
"dd": "^0.
|
|
30
|
+
"dd": "^0.18.0",
|
|
32
31
|
"dotenv": "^10.0.0",
|
|
33
|
-
"eslint": "^8.0
|
|
32
|
+
"eslint": "^8.6.0",
|
|
34
33
|
"eslint-config-prettier": "^8.3.0",
|
|
35
|
-
"eslint-plugin-import": "^2.25.
|
|
34
|
+
"eslint-plugin-import": "^2.25.4",
|
|
36
35
|
"eslint-plugin-prettier": "^4.0.0",
|
|
37
|
-
"eslint-plugin-promise": "^
|
|
38
|
-
"
|
|
36
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
37
|
+
"eslint-plugin-unicorn": "^40.0.0",
|
|
38
|
+
"jest": "^27.4.7",
|
|
39
39
|
"jest-extended": "~1.2.0",
|
|
40
40
|
"npm-run-all": "~4.1.5",
|
|
41
|
-
"prettier": "~2.5.
|
|
41
|
+
"prettier": "~2.5.1",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
|
-
"ts-jest": "^27.
|
|
44
|
-
"ts-node": "^10.
|
|
45
|
-
"tsup": "^5.
|
|
46
|
-
"typescript": "^4.
|
|
47
|
-
},
|
|
48
|
-
"optionalDependencies": {
|
|
49
|
-
"common-types": "^1.30.0"
|
|
43
|
+
"ts-jest": "^27.1.2",
|
|
44
|
+
"ts-node": "^10.4.0",
|
|
45
|
+
"tsup": "^5.11.11",
|
|
46
|
+
"typescript": "^4.5.4"
|
|
50
47
|
},
|
|
51
48
|
"dependencies": {
|
|
52
|
-
"
|
|
53
|
-
"native-dash": "^1.20.1"
|
|
49
|
+
"common-types": "^1.31.0"
|
|
54
50
|
}
|
|
55
51
|
}
|