inferred-types 0.18.3 → 0.19.1
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 +28 -2
- package/dist/index.js +18 -0
- package/dist/index.mjs +16 -0
- package/on-hold/Builder/index.ts +2 -2
- package/on-hold/types/index.ts +2 -2
- package/package.json +15 -12
- package/src/Mutation/index.ts +2 -2
- package/src/index.ts +2 -2
- package/src/shared/index.ts +2 -2
- package/src/types/FunctionType.ts +1 -1
- 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 +25 -0
- package/src/utility/dictionary/index.ts +2 -2
- 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/index.ts +2 -2
- package/tests/data/index.ts +2 -2
- package/pnpm-lock.yaml +0 -6388
package/dist/index.d.ts
CHANGED
|
@@ -899,6 +899,11 @@ declare type SnakeCase<S extends string> = string extends S ? string : DashUpper
|
|
|
899
899
|
*/
|
|
900
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;
|
|
901
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
|
+
|
|
902
907
|
/**
|
|
903
908
|
* **ToFluent**
|
|
904
909
|
*
|
|
@@ -1037,7 +1042,7 @@ declare type FirstKeyValue<T extends object> = FirstKey<T> extends keyof T ? T[F
|
|
|
1037
1042
|
declare type FirstOfEach<T extends readonly any[][]> = T[number][0] extends T[number][number] ? T[number][0] : never;
|
|
1038
1043
|
|
|
1039
1044
|
/**
|
|
1040
|
-
* Typescript utility which
|
|
1045
|
+
* Typescript utility which receives `T` as shape which resembles `DictArray<D>`
|
|
1041
1046
|
* and if the type `D` can be inferred it is returned.
|
|
1042
1047
|
* ```ts
|
|
1043
1048
|
* // { foo: 1; bar: "hi" }
|
|
@@ -1082,6 +1087,19 @@ declare type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) =>
|
|
|
1082
1087
|
*/
|
|
1083
1088
|
declare type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...UnionToTuple<Exclude<U, Last>>, Last];
|
|
1084
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
|
+
|
|
1085
1103
|
declare type ValueFunction<T extends any> = <R extends any>(v: T) => R;
|
|
1086
1104
|
/**
|
|
1087
1105
|
* **SameKeys**
|
|
@@ -1096,6 +1114,14 @@ declare type WrapValue<T extends {}, F extends ValueFunction<T>> = {
|
|
|
1096
1114
|
};
|
|
1097
1115
|
|
|
1098
1116
|
declare function createFnWithProps<F extends Function, P extends {}>(fn: F, props: P): F & P;
|
|
1117
|
+
/**
|
|
1118
|
+
* Adds a dictionary of key/value pairs to a function.
|
|
1119
|
+
*/
|
|
1120
|
+
declare function fnWithProps<A extends any[], R extends any, P extends {}>(fn: ((...args: A) => R), props: P): ((...args: A) => R) & P;
|
|
1121
|
+
/**
|
|
1122
|
+
* Adds read-only (and narrowly typed) key/value pairs to a function
|
|
1123
|
+
*/
|
|
1124
|
+
declare function readonlyFnWithProps<A extends any[], R extends any, N extends Narrowable, P extends Record<keyof P, N>>(fn: ((...args: A) => R), props: P): ((...args: A) => R) & Readonly<P>;
|
|
1099
1125
|
|
|
1100
1126
|
/**
|
|
1101
1127
|
* Provides the _keys_ of an object with the `keyof T` made explicit.
|
|
@@ -9770,4 +9796,4 @@ declare function KeyStorage(): {
|
|
|
9770
9796
|
done: () => never[];
|
|
9771
9797
|
};
|
|
9772
9798
|
|
|
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 };
|
|
9799
|
+
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, fnWithProps, 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, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, valuesOfProp, withValue };
|
package/dist/index.js
CHANGED
|
@@ -60,6 +60,7 @@ __export(src_exports, {
|
|
|
60
60
|
entries: () => entries,
|
|
61
61
|
equals: () => equals,
|
|
62
62
|
filterDictArray: () => filterDictArray,
|
|
63
|
+
fnWithProps: () => fnWithProps,
|
|
63
64
|
greater: () => greater,
|
|
64
65
|
groupBy: () => groupBy,
|
|
65
66
|
idLiteral: () => idLiteral,
|
|
@@ -89,6 +90,7 @@ __export(src_exports, {
|
|
|
89
90
|
nameLiteral: () => nameLiteral,
|
|
90
91
|
or: () => or,
|
|
91
92
|
randomString: () => randomString,
|
|
93
|
+
readonlyFnWithProps: () => readonlyFnWithProps,
|
|
92
94
|
ruleSet: () => ruleSet,
|
|
93
95
|
strArrayToDict: () => strArrayToDict,
|
|
94
96
|
type: () => type,
|
|
@@ -158,6 +160,20 @@ function createFnWithProps(fn, props) {
|
|
|
158
160
|
return combined;
|
|
159
161
|
})();
|
|
160
162
|
}
|
|
163
|
+
function fnWithProps(fn, props) {
|
|
164
|
+
let combined = fn;
|
|
165
|
+
for (const prop of keys(props)) {
|
|
166
|
+
combined[prop] = props[prop];
|
|
167
|
+
}
|
|
168
|
+
return combined;
|
|
169
|
+
}
|
|
170
|
+
function readonlyFnWithProps(fn, props) {
|
|
171
|
+
let combined = fn;
|
|
172
|
+
for (const prop of keys(props)) {
|
|
173
|
+
combined[prop] = props[prop];
|
|
174
|
+
}
|
|
175
|
+
return combined;
|
|
176
|
+
}
|
|
161
177
|
|
|
162
178
|
// src/utility/ruleset.ts
|
|
163
179
|
function ruleSet(defn) {
|
|
@@ -641,6 +657,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
641
657
|
entries,
|
|
642
658
|
equals,
|
|
643
659
|
filterDictArray,
|
|
660
|
+
fnWithProps,
|
|
644
661
|
greater,
|
|
645
662
|
groupBy,
|
|
646
663
|
idLiteral,
|
|
@@ -670,6 +687,7 @@ module.exports = __toCommonJS(src_exports);
|
|
|
670
687
|
nameLiteral,
|
|
671
688
|
or,
|
|
672
689
|
randomString,
|
|
690
|
+
readonlyFnWithProps,
|
|
673
691
|
ruleSet,
|
|
674
692
|
strArrayToDict,
|
|
675
693
|
type,
|
package/dist/index.mjs
CHANGED
|
@@ -77,6 +77,20 @@ function createFnWithProps(fn, props) {
|
|
|
77
77
|
return combined;
|
|
78
78
|
})();
|
|
79
79
|
}
|
|
80
|
+
function fnWithProps(fn, props) {
|
|
81
|
+
let combined = fn;
|
|
82
|
+
for (const prop of keys(props)) {
|
|
83
|
+
combined[prop] = props[prop];
|
|
84
|
+
}
|
|
85
|
+
return combined;
|
|
86
|
+
}
|
|
87
|
+
function readonlyFnWithProps(fn, props) {
|
|
88
|
+
let combined = fn;
|
|
89
|
+
for (const prop of keys(props)) {
|
|
90
|
+
combined[prop] = props[prop];
|
|
91
|
+
}
|
|
92
|
+
return combined;
|
|
93
|
+
}
|
|
80
94
|
|
|
81
95
|
// src/utility/ruleset.ts
|
|
82
96
|
function ruleSet(defn) {
|
|
@@ -558,6 +572,7 @@ export {
|
|
|
558
572
|
entries,
|
|
559
573
|
equals,
|
|
560
574
|
filterDictArray,
|
|
575
|
+
fnWithProps,
|
|
561
576
|
greater,
|
|
562
577
|
groupBy,
|
|
563
578
|
idLiteral,
|
|
@@ -587,6 +602,7 @@ export {
|
|
|
587
602
|
nameLiteral,
|
|
588
603
|
or,
|
|
589
604
|
randomString,
|
|
605
|
+
readonlyFnWithProps,
|
|
590
606
|
ruleSet,
|
|
591
607
|
strArrayToDict,
|
|
592
608
|
type,
|
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.1",
|
|
4
4
|
"description": "Functions which provide useful type inference on TS projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Ken Snyder<ken@ken.net>",
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"build": "run-s clean autoindex lint build:bundle",
|
|
15
15
|
"build:force": "run-s clean autoindex build:bundle",
|
|
16
16
|
"build:bundle": "npx tsup src/index.ts --dts --format='esm,cjs'",
|
|
17
|
+
"watch": "run-p watch:*",
|
|
18
|
+
"watch:autoindex": "npx dd autoindex --watch",
|
|
19
|
+
"watch:bundle": "npx tsup src/index.ts --dts --format='esm,cjs' --watch",
|
|
17
20
|
"clean": "rimraf dist/**/*",
|
|
18
21
|
"lint": "eslint src/**/*.ts --fix && tsc --noEmit ",
|
|
19
22
|
"lint:full": "eslint src/**/*.ts && eslint test/**/*.ts && tsc --noEmit",
|
|
@@ -21,31 +24,31 @@
|
|
|
21
24
|
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@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.
|
|
27
|
+
"@types/jest": "^27.4.0",
|
|
28
|
+
"@types/node": "^14.18.5",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
30
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
28
31
|
"common-types": "^1.30.0",
|
|
29
32
|
"cross-env": "^7.0.3",
|
|
30
|
-
"dd": "^0.
|
|
33
|
+
"dd": "^0.18.0",
|
|
31
34
|
"dotenv": "^10.0.0",
|
|
32
|
-
"eslint": "^8.
|
|
35
|
+
"eslint": "^8.6.0",
|
|
33
36
|
"eslint-config-prettier": "^8.3.0",
|
|
34
|
-
"eslint-plugin-import": "^2.25.
|
|
37
|
+
"eslint-plugin-import": "^2.25.4",
|
|
35
38
|
"eslint-plugin-prettier": "^4.0.0",
|
|
36
39
|
"eslint-plugin-promise": "^6.0.0",
|
|
37
|
-
"eslint-plugin-unicorn": "^
|
|
38
|
-
"jest": "^27.4.
|
|
40
|
+
"eslint-plugin-unicorn": "^40.0.0",
|
|
41
|
+
"jest": "^27.4.7",
|
|
39
42
|
"jest-extended": "~1.2.0",
|
|
40
43
|
"npm-run-all": "~4.1.5",
|
|
41
44
|
"prettier": "~2.5.1",
|
|
42
45
|
"rimraf": "^3.0.2",
|
|
43
46
|
"ts-jest": "^27.1.2",
|
|
44
47
|
"ts-node": "^10.4.0",
|
|
45
|
-
"tsup": "^5.11.
|
|
48
|
+
"tsup": "^5.11.11",
|
|
46
49
|
"typescript": "^4.5.4"
|
|
47
50
|
},
|
|
48
51
|
"dependencies": {
|
|
49
52
|
"common-types": "^1.31.0"
|
|
50
53
|
}
|
|
51
|
-
}
|
|
54
|
+
}
|
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";
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { Narrowable } from "../types/Narrowable";
|
|
1
2
|
import { keys } from "./keys";
|
|
2
3
|
|
|
3
4
|
export function createFnWithProps<F extends Function, P extends {}>(fn: F, props: P) {
|
|
@@ -10,3 +11,27 @@ export function createFnWithProps<F extends Function, P extends {}>(fn: F, props
|
|
|
10
11
|
return combined;
|
|
11
12
|
})() as unknown as F & P;
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Adds a dictionary of key/value pairs to a function.
|
|
17
|
+
*/
|
|
18
|
+
export function fnWithProps<A extends any[], R extends any, P extends {}>(fn: ((...args: A) => R), props: P) {
|
|
19
|
+
// eslint-disable-next-line prefer-const
|
|
20
|
+
let combined: any = fn;
|
|
21
|
+
for (const prop of keys(props)) {
|
|
22
|
+
combined[prop] = props[prop];
|
|
23
|
+
}
|
|
24
|
+
return combined as ((...args: A) => R) & P;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds read-only (and narrowly typed) key/value pairs to a function
|
|
29
|
+
*/
|
|
30
|
+
export function readonlyFnWithProps<A extends any[], R extends any, N extends Narrowable, P extends Record<keyof P, N>>(fn: ((...args: A) => R), props: P) {
|
|
31
|
+
// eslint-disable-next-line prefer-const
|
|
32
|
+
let combined: any = fn;
|
|
33
|
+
for (const prop of keys(props)) {
|
|
34
|
+
combined[prop] = props[prop];
|
|
35
|
+
}
|
|
36
|
+
return combined as ((...args: A) => R) & Readonly<P>;
|
|
37
|
+
}
|
|
@@ -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: c3587066
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./arrayToKeyLookup";
|
|
@@ -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";
|
|
@@ -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: fd5dfde8
|
|
5
5
|
|
|
6
6
|
// file exports
|
|
7
7
|
export * from "./Configurator";
|
package/tests/data/index.ts
CHANGED