inferred-types 0.18.2 → 0.19.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 +24 -13
- package/dist/index.js +5 -11
- package/dist/index.mjs +5 -10
- package/on-hold/Builder/index.ts +2 -2
- package/on-hold/types/index.ts +2 -2
- package/package.json +13 -15
- package/src/Mutation/index.ts +2 -2
- package/src/index.ts +2 -2
- package/src/shared/index.ts +2 -2
- package/src/types/Where.ts +19 -15
- package/src/types/alphabetic/index.ts +2 -2
- package/src/types/dictionary/NotEmptyObject.ts +9 -0
- package/src/types/dictionary/index.ts +3 -2
- package/src/types/fluent/index.ts +2 -2
- package/src/types/index.ts +2 -2
- package/src/types/kv/index.ts +2 -2
- package/src/types/lists/index.ts +2 -2
- package/src/types/string-literals/index.ts +2 -2
- package/src/types/tuples/FromDictArray.ts +1 -1
- package/src/types/tuples/index.ts +2 -2
- package/src/types/type-conversion/UnwrapValue.ts +13 -0
- package/src/types/type-conversion/index.ts +3 -2
- package/src/utility/api/index.ts +2 -2
- package/src/utility/createFnWithProps.ts +1 -1
- package/src/utility/dictionary/index.ts +2 -3
- package/src/utility/dictionary/kv/index.ts +2 -2
- package/src/utility/index.ts +2 -2
- package/src/utility/lists/index.ts +2 -2
- package/src/utility/literals/index.ts +2 -2
- package/src/utility/map-reduce/index.ts +2 -2
- package/src/utility/modelling/index.ts +2 -2
- package/src/utility/runtime/conditions/index.ts +2 -2
- package/src/utility/runtime/index.ts +2 -2
- package/src/utility/state/Configurator.ts +12 -3
- package/src/utility/state/index.ts +2 -2
- package/tests/data/index.ts +2 -2
- package/tests/kv/dict-to-kv-and-back.spec.ts +24 -22
- package/.tsbuildinfo +0 -1
- package/pnpm-lock.yaml +0 -6388
- package/src/utility/dictionary/dictFilter.ts +0 -19
- package/tests/kv/dictFilter.ts +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Include as Include$1 } from 'native-dash';
|
|
2
1
|
import { Alpha as Alpha$1 } from 'common-types';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -326,7 +325,7 @@ declare type TypeGuard<T> = (thing: unknown) => thing is T;
|
|
|
326
325
|
* type BA = Where<typeof arr, `ba${string}`>;
|
|
327
326
|
* ```
|
|
328
327
|
*/
|
|
329
|
-
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> : {
|
|
330
329
|
[K in keyof T]: K extends U ? K : never;
|
|
331
330
|
}[keyof T];
|
|
332
331
|
/**
|
|
@@ -900,6 +899,11 @@ declare type SnakeCase<S extends string> = string extends S ? string : DashUpper
|
|
|
900
899
|
*/
|
|
901
900
|
declare type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T ? Get<T[FK], L> : never : K extends keyof T ? T[K] : never;
|
|
902
901
|
|
|
902
|
+
/**
|
|
903
|
+
* Accepts an object with at least one property defined on it
|
|
904
|
+
*/
|
|
905
|
+
declare type NotEmptyObject<T extends {}> = ExpandRecursively<Length<UnionToTuple<Keys<T>>> extends 0 ? false : T>;
|
|
906
|
+
|
|
903
907
|
/**
|
|
904
908
|
* **ToFluent**
|
|
905
909
|
*
|
|
@@ -1038,7 +1042,7 @@ declare type FirstKeyValue<T extends object> = FirstKey<T> extends keyof T ? T[F
|
|
|
1038
1042
|
declare type FirstOfEach<T extends readonly any[][]> = T[number][0] extends T[number][number] ? T[number][0] : never;
|
|
1039
1043
|
|
|
1040
1044
|
/**
|
|
1041
|
-
* Typescript utility which
|
|
1045
|
+
* Typescript utility which receives `T` as shape which resembles `DictArray<D>`
|
|
1042
1046
|
* and if the type `D` can be inferred it is returned.
|
|
1043
1047
|
* ```ts
|
|
1044
1048
|
* // { foo: 1; bar: "hi" }
|
|
@@ -1083,6 +1087,19 @@ declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) =>
|
|
|
1083
1087
|
*/
|
|
1084
1088
|
declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
|
|
1085
1089
|
|
|
1090
|
+
/**
|
|
1091
|
+
* Given a dictionary of key/values, where the value is a function, this
|
|
1092
|
+
* type utility will maintain the keys but change the values to whatever
|
|
1093
|
+
* the `ReturnType` of the function was.
|
|
1094
|
+
* ```ts
|
|
1095
|
+
* // { foo: string }
|
|
1096
|
+
* type Test = UnwrapValue<{ foo: (name: string) => name }>
|
|
1097
|
+
* ```
|
|
1098
|
+
*/
|
|
1099
|
+
declare type UnwrapValue<T extends Record<string, (...args: any[]) => any>> = {
|
|
1100
|
+
[K in keyof T]: T[K] extends Function ? ReturnType<T[K]> : never;
|
|
1101
|
+
}[keyof T];
|
|
1102
|
+
|
|
1086
1103
|
declare type ValueFunction<T extends any> = <R extends any>(v: T) => R;
|
|
1087
1104
|
/**
|
|
1088
1105
|
* **SameKeys**
|
|
@@ -1133,14 +1150,6 @@ declare const api: <N extends Narrowable, TPrivate extends Readonly<Record<any,
|
|
|
1133
1150
|
*/
|
|
1134
1151
|
declare function arrayToKeyLookup<T extends readonly string[]>(...keys: T): Record<T[number], true>;
|
|
1135
1152
|
|
|
1136
|
-
declare type ObjFilterCallback<T extends object, R extends boolean> = (k: keyof T, state: T) => R;
|
|
1137
|
-
/**
|
|
1138
|
-
* **dictFilter**
|
|
1139
|
-
*
|
|
1140
|
-
* Provides a means ot filter down the properties on a given object.
|
|
1141
|
-
*/
|
|
1142
|
-
declare function dictFilter<N extends Narrowable, T extends Record<string, N>, R extends boolean>(obj: T, cb: ObjFilterCallback<T, R>): Exclude<T, (keyof T)[]>;
|
|
1143
|
-
|
|
1144
1153
|
/**
|
|
1145
1154
|
* Takes a dictionary of type `I` and converts it to a dictionary of type `O` where
|
|
1146
1155
|
* they _keys_ used in both dictionaries are the same.
|
|
@@ -1518,11 +1527,13 @@ declare function type<T extends any, V extends Function>(fn: TypeDefinition<T, V
|
|
|
1518
1527
|
*/
|
|
1519
1528
|
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>>>;
|
|
1520
1529
|
|
|
1530
|
+
declare type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
1531
|
+
|
|
1521
1532
|
interface IConfigurator<C = {}> {
|
|
1522
1533
|
set<V, K extends string, KV = {
|
|
1523
1534
|
[U in K]: V;
|
|
1524
1535
|
}>(key: K, value: V): asserts this is IConfigurator<ExpandRecursively<C & KV>>;
|
|
1525
|
-
remove<K extends string & keyof C>(key: K): asserts this is IConfigurator<ExpandRecursively<Omit<C, K>>>;
|
|
1536
|
+
remove<K extends string & keyof C>(key: K): asserts this is IConfigurator<ExpandRecursively<Omit$1<C, K>>>;
|
|
1526
1537
|
done(): C;
|
|
1527
1538
|
}
|
|
1528
1539
|
/**
|
|
@@ -9777,4 +9788,4 @@ declare function KeyStorage(): {
|
|
|
9777
9788
|
done: () => never[];
|
|
9778
9789
|
};
|
|
9779
9790
|
|
|
9780
|
-
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,
|
|
9791
|
+
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, NotEmptyObject, 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, UnwrapValue, 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
|
@@ -55,7 +55,6 @@ __export(src_exports, {
|
|
|
55
55
|
createFnWithProps: () => createFnWithProps,
|
|
56
56
|
createMutationFunction: () => createMutationFunction,
|
|
57
57
|
defineType: () => defineType,
|
|
58
|
-
dictFilter: () => dictFilter,
|
|
59
58
|
dictToKv: () => dictToKv,
|
|
60
59
|
dictionaryTransform: () => dictionaryTransform,
|
|
61
60
|
entries: () => entries,
|
|
@@ -181,13 +180,6 @@ function arrayToKeyLookup(...keys2) {
|
|
|
181
180
|
return obj;
|
|
182
181
|
}
|
|
183
182
|
|
|
184
|
-
// src/utility/dictionary/dictFilter.ts
|
|
185
|
-
var import_native_dash = require("native-dash");
|
|
186
|
-
function dictFilter(obj, cb) {
|
|
187
|
-
const remove = keys(obj).filter((k) => !cb(k, obj));
|
|
188
|
-
return (0, import_native_dash.omit)(obj, ...keys(obj).filter((k) => !cb(k, obj)));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
183
|
// src/utility/dictionary/dictionaryTransform.ts
|
|
192
184
|
function dictionaryTransform(input, transform) {
|
|
193
185
|
return keys(input).reduce((acc, i) => {
|
|
@@ -233,7 +225,10 @@ function dictToKv(obj, _makeTuple = false) {
|
|
|
233
225
|
}
|
|
234
226
|
|
|
235
227
|
// src/utility/state/Configurator.ts
|
|
236
|
-
|
|
228
|
+
function omit(obj, ...removals) {
|
|
229
|
+
const untyped = removals;
|
|
230
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
231
|
+
}
|
|
237
232
|
function Configurator() {
|
|
238
233
|
let configuration = () => ({});
|
|
239
234
|
const api2 = () => {
|
|
@@ -247,7 +242,7 @@ function Configurator() {
|
|
|
247
242
|
},
|
|
248
243
|
remove(key) {
|
|
249
244
|
const config = configuration();
|
|
250
|
-
const updated =
|
|
245
|
+
const updated = omit(config, key);
|
|
251
246
|
configuration = () => updated;
|
|
252
247
|
return updated;
|
|
253
248
|
},
|
|
@@ -641,7 +636,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
641
636
|
createFnWithProps,
|
|
642
637
|
createMutationFunction,
|
|
643
638
|
defineType,
|
|
644
|
-
dictFilter,
|
|
645
639
|
dictToKv,
|
|
646
640
|
dictionaryTransform,
|
|
647
641
|
entries,
|
package/dist/index.mjs
CHANGED
|
@@ -99,13 +99,6 @@ function arrayToKeyLookup(...keys2) {
|
|
|
99
99
|
return obj;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// src/utility/dictionary/dictFilter.ts
|
|
103
|
-
import { omit } from "native-dash";
|
|
104
|
-
function dictFilter(obj, cb) {
|
|
105
|
-
const remove = keys(obj).filter((k) => !cb(k, obj));
|
|
106
|
-
return omit(obj, ...keys(obj).filter((k) => !cb(k, obj)));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
102
|
// src/utility/dictionary/dictionaryTransform.ts
|
|
110
103
|
function dictionaryTransform(input, transform) {
|
|
111
104
|
return keys(input).reduce((acc, i) => {
|
|
@@ -151,7 +144,10 @@ function dictToKv(obj, _makeTuple = false) {
|
|
|
151
144
|
}
|
|
152
145
|
|
|
153
146
|
// src/utility/state/Configurator.ts
|
|
154
|
-
|
|
147
|
+
function omit(obj, ...removals) {
|
|
148
|
+
const untyped = removals;
|
|
149
|
+
return Object.fromEntries(Object.entries(obj).filter(([key]) => !untyped.includes(key)));
|
|
150
|
+
}
|
|
155
151
|
function Configurator() {
|
|
156
152
|
let configuration = () => ({});
|
|
157
153
|
const api2 = () => {
|
|
@@ -165,7 +161,7 @@ function Configurator() {
|
|
|
165
161
|
},
|
|
166
162
|
remove(key) {
|
|
167
163
|
const config = configuration();
|
|
168
|
-
const updated =
|
|
164
|
+
const updated = omit(config, key);
|
|
169
165
|
configuration = () => updated;
|
|
170
166
|
return updated;
|
|
171
167
|
},
|
|
@@ -557,7 +553,6 @@ export {
|
|
|
557
553
|
createFnWithProps,
|
|
558
554
|
createMutationFunction,
|
|
559
555
|
defineType,
|
|
560
|
-
dictFilter,
|
|
561
556
|
dictToKv,
|
|
562
557
|
dictionaryTransform,
|
|
563
558
|
entries,
|
package/on-hold/Builder/index.ts
CHANGED
package/on-hold/types/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inferred-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Functions which provide useful type inference on TS projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ken Snyder<ken@ken.net>",
|
|
@@ -21,33 +21,31 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@type-challenges/utils": "~0.1.1",
|
|
24
|
-
"@types/jest": "^27.0
|
|
25
|
-
"@types/node": "^14.18.
|
|
26
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
27
|
-
"@typescript-eslint/parser": "^5.
|
|
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",
|
|
28
28
|
"common-types": "^1.30.0",
|
|
29
29
|
"cross-env": "^7.0.3",
|
|
30
|
-
"dd": "^0.
|
|
30
|
+
"dd": "^0.18.0",
|
|
31
31
|
"dotenv": "^10.0.0",
|
|
32
|
-
"eslint": "^8.
|
|
32
|
+
"eslint": "^8.6.0",
|
|
33
33
|
"eslint-config-prettier": "^8.3.0",
|
|
34
|
-
"eslint-plugin-import": "^2.25.
|
|
34
|
+
"eslint-plugin-import": "^2.25.4",
|
|
35
35
|
"eslint-plugin-prettier": "^4.0.0",
|
|
36
36
|
"eslint-plugin-promise": "^6.0.0",
|
|
37
|
-
"eslint-plugin-unicorn": "^
|
|
38
|
-
"jest": "^27.4.
|
|
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
41
|
"prettier": "~2.5.1",
|
|
42
42
|
"rimraf": "^3.0.2",
|
|
43
43
|
"ts-jest": "^27.1.2",
|
|
44
44
|
"ts-node": "^10.4.0",
|
|
45
|
-
"tsup": "^5.11.
|
|
45
|
+
"tsup": "^5.11.11",
|
|
46
46
|
"typescript": "^4.5.4"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"
|
|
50
|
-
"common-types": "^1.31.0",
|
|
51
|
-
"native-dash": "^1.21.2"
|
|
49
|
+
"common-types": "^1.31.0"
|
|
52
50
|
}
|
|
53
|
-
}
|
|
51
|
+
}
|
package/src/Mutation/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: f6badae2
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./MutationFunction";
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: 3f75741a
|
|
6
6
|
|
|
7
7
|
// directory exports
|
|
8
8
|
export * from "./Mutation/index";
|
package/src/shared/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex: orphan
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: 58ead14b
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./randomString";
|
package/src/types/Where.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { Include } from "
|
|
2
|
-
|
|
1
|
+
import { Include } from "./Include";
|
|
3
2
|
/**
|
|
4
3
|
* Allows filtering down `T` to those which extend a given type `U`.
|
|
5
|
-
*
|
|
4
|
+
*
|
|
6
5
|
* - `T` is either a dictionary (where keys will be used to compare) or
|
|
7
6
|
* a readonly sting array.
|
|
8
7
|
* ```ts
|
|
@@ -11,16 +10,18 @@ import { Include } from "native-dash";
|
|
|
11
10
|
* type BA = Where<typeof arr, `ba${string}`>;
|
|
12
11
|
* ```
|
|
13
12
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
export type Where<
|
|
14
|
+
T extends Record<string, any> | readonly string[],
|
|
15
|
+
U
|
|
16
|
+
> = T extends readonly string[]
|
|
17
|
+
? Include<T[number], U>
|
|
18
|
+
: {
|
|
19
|
+
[K in keyof T]: K extends U ? K : never;
|
|
20
|
+
}[keyof T];
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Allows filtering down `T` to those which extend a given type `U`.
|
|
23
|
-
*
|
|
24
|
+
*
|
|
24
25
|
* - `T` is either a dictionary (where keys will be used to compare) or
|
|
25
26
|
* a readonly sting array.
|
|
26
27
|
* ```ts
|
|
@@ -29,8 +30,11 @@ import { Include } from "native-dash";
|
|
|
29
30
|
* type F = WhereNot<typeof arr, `ba${string}`>;
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export type WhereNot<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
export type WhereNot<
|
|
34
|
+
T extends Record<string, any> | readonly string[],
|
|
35
|
+
U
|
|
36
|
+
> = T extends readonly string[]
|
|
37
|
+
? Exclude<T[number], U>
|
|
38
|
+
: {
|
|
39
|
+
[K in keyof T]: K extends U ? never : K;
|
|
40
|
+
}[keyof T];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex, exclude: Alpha
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: fcf9c4b
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./AllCaps";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExpandRecursively } from "../ExpandRecursively";
|
|
2
|
+
import { Keys, Length, UnionToTuple } from "../index";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Accepts an object with at least one property defined on it
|
|
6
|
+
*/
|
|
7
|
+
export type NotEmptyObject<T extends {}> = ExpandRecursively<
|
|
8
|
+
Length<UnionToTuple<Keys<T>>> extends 0 ? false : T
|
|
9
|
+
>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 6th Jun, 2022, 03:36 AM ( GMT-7 )
|
|
4
|
+
// hash-code: 1f3a5076
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Get";
|
|
8
|
+
export * from "./NotEmptyObject";
|
|
8
9
|
|
|
9
10
|
// #endregion
|
|
10
11
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: c5fbce38
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./fluent";
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: 7e6e29a0
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Api";
|
package/src/types/kv/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: abd196de
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./DictFromKv";
|
package/src/types/lists/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: 61af00e2
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./UniqueForProp";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: a80cfdd7
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Break";
|
|
@@ -2,7 +2,7 @@ import { ExpandRecursively, UnionToIntersection } from "~/types";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Typescript utility which
|
|
5
|
+
* Typescript utility which receives `T` as shape which resembles `DictArray<D>`
|
|
6
6
|
* and if the type `D` can be inferred it is returned.
|
|
7
7
|
* ```ts
|
|
8
8
|
* // { foo: 1; bar: "hi" }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: 37b8bb67
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./DictArray";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Given a dictionary of key/values, where the value is a function, this
|
|
4
|
+
* type utility will maintain the keys but change the values to whatever
|
|
5
|
+
* the `ReturnType` of the function was.
|
|
6
|
+
* ```ts
|
|
7
|
+
* // { foo: string }
|
|
8
|
+
* type Test = UnwrapValue<{ foo: (name: string) => name }>
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export type UnwrapValue<T extends Record<string, (...args: any[]) => any>> = {
|
|
12
|
+
[K in keyof T]: T[K] extends Function ? ReturnType<T[K]> : never;
|
|
13
|
+
}[keyof T];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 6th Jun, 2022, 03:36 AM ( GMT-7 )
|
|
5
|
+
// hash-code: ac142b94
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./SameKeys";
|
|
9
9
|
export * from "./TupleToUnion";
|
|
10
10
|
export * from "./UnionToIntersection";
|
|
11
11
|
export * from "./UnionToTuple";
|
|
12
|
+
export * from "./UnwrapValue";
|
|
12
13
|
export * from "./WrapValue";
|
|
13
14
|
|
|
14
15
|
// #endregion
|
package/src/utility/api/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: d2d3ad38
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./api";
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: c3587066
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./arrayToKeyLookup";
|
|
8
|
-
export * from "./dictFilter";
|
|
9
8
|
export * from "./dictionaryTransform";
|
|
10
9
|
export * from "./entries";
|
|
11
10
|
export * from "./mapValues";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: e1ea6f41
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./dictToKv";
|
package/src/utility/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: 6886d37a
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./createFnWithProps";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: 150c313
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./groupBy";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: b7a5f43
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./ExplicitFunction";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: 73454cdf
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./filter";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex, exclude: IoModel
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: 34d6be17
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Model";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
|
|
3
3
|
// #region autoindexed files
|
|
4
|
-
// index last changed at:
|
|
5
|
-
// hash-code:
|
|
4
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
5
|
+
// hash-code: a3788912
|
|
6
6
|
|
|
7
7
|
// file exports
|
|
8
8
|
export * from "./isArray";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// #autoindex
|
|
2
2
|
// #region autoindexed files
|
|
3
|
-
// index last changed at:
|
|
4
|
-
// hash-code:
|
|
3
|
+
// index last changed at: 1st Jan, 2022, 03:27 PM ( GMT-8 )
|
|
4
|
+
// hash-code: 91796b6
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./condition";
|