inferred-types 0.23.0 → 0.23.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 +19 -1
- package/dist/index.js +5 -0
- package/dist/index.mjs +4 -0
- package/package.json +1 -1
- package/src/utility/dictionary/index.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1438,6 +1438,24 @@ declare function entries<N extends Narrowable, T extends Record<string, N>, I ex
|
|
|
1438
1438
|
*/
|
|
1439
1439
|
declare function mapValues<N extends Narrowable, T extends Record<string, N>, V>(obj: T, valueMapper: (k: T[keyof T]) => V): { [K in keyof T]: V; };
|
|
1440
1440
|
|
|
1441
|
+
/**
|
|
1442
|
+
* **mapTo**
|
|
1443
|
+
*
|
|
1444
|
+
* A utility function which maps one dictionary structure `I` to another `O`; where:
|
|
1445
|
+
*
|
|
1446
|
+
* - `I` maps to `O[ ]` so this allows a cardinality of 0:M
|
|
1447
|
+
* - In other words ... values from `I` can be filtered, translated 1:1 or split into multiple outputs
|
|
1448
|
+
* - Type constrains laid out by `I` and `O` will be enforced by type system
|
|
1449
|
+
*
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* type I = { title: string; color: string; products: Product[] };
|
|
1452
|
+
* type O = { title: string; count: number };
|
|
1453
|
+
* const summarize: mapTo<I,O>()
|
|
1454
|
+
* .map();
|
|
1455
|
+
* ```
|
|
1456
|
+
*/
|
|
1457
|
+
declare const mapTo: <I extends {}, O extends {}>(cb: MapTo<I, O>) => (source: I) => O[];
|
|
1458
|
+
|
|
1441
1459
|
/**
|
|
1442
1460
|
* converts an array of strings `["a", "b", "c"]` into a more type friendly
|
|
1443
1461
|
* dictionary of the type `{ a: true, b: true, c: true }`
|
|
@@ -1721,4 +1739,4 @@ interface IFluentConfigurator<C> {
|
|
|
1721
1739
|
*/
|
|
1722
1740
|
declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
|
|
1723
1741
|
|
|
1724
|
-
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, DefinePropertiesApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, Filter, FinalReturn, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsCapitalized, IsFalse, IsFunction, IsObject, IsString, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LowerAllCaps, LowerAlpha, MapTo, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, Numeric, NumericKeys, NumericString, ObjectType, Opaque, OpeningBracket, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, 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, ZipCode, and, api, arrayToKeyLookup, arrayToObject, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictToKv, dictionaryTransform, entries, equals, filterDictArray, fnWithProps, greater, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, 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, withValue };
|
|
1742
|
+
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, DefinePropertiesApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, ExtendsClause, ExtendsNarrowlyClause, Filter, FinalReturn, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfExtends, IfExtendsThen, Include, Includes, IsArray, IsBoolean, IsCapitalized, IsFalse, IsFunction, IsObject, IsString, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LowerAllCaps, LowerAlpha, MapTo, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, Numeric, NumericKeys, NumericString, ObjectType, Opaque, OpeningBracket, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimplifyObject, 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, ZipCode, and, api, arrayToKeyLookup, arrayToObject, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictToKv, dictionaryTransform, entries, equals, filterDictArray, fnWithProps, greater, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNull, isNumber, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, less, literal, mapTo, mapValues, nameLiteral, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,7 @@ __export(src_exports, {
|
|
|
64
64
|
kvToDict: () => kvToDict,
|
|
65
65
|
less: () => less,
|
|
66
66
|
literal: () => literal,
|
|
67
|
+
mapTo: () => mapTo,
|
|
67
68
|
mapValues: () => mapValues,
|
|
68
69
|
nameLiteral: () => nameLiteral,
|
|
69
70
|
or: () => or,
|
|
@@ -221,6 +222,9 @@ function mapValues(obj, valueMapper) {
|
|
|
221
222
|
);
|
|
222
223
|
}
|
|
223
224
|
|
|
225
|
+
// src/utility/dictionary/mapTo.ts
|
|
226
|
+
var mapTo = (cb) => (source) => cb(source);
|
|
227
|
+
|
|
224
228
|
// src/utility/dictionary/strArrayToDict.ts
|
|
225
229
|
function strArrayToDict(...strings) {
|
|
226
230
|
return strings.reduce((acc, str) => {
|
|
@@ -665,6 +669,7 @@ function withValue(td) {
|
|
|
665
669
|
kvToDict,
|
|
666
670
|
less,
|
|
667
671
|
literal,
|
|
672
|
+
mapTo,
|
|
668
673
|
mapValues,
|
|
669
674
|
nameLiteral,
|
|
670
675
|
or,
|
package/dist/index.mjs
CHANGED
|
@@ -140,6 +140,9 @@ function mapValues(obj, valueMapper) {
|
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
// src/utility/dictionary/mapTo.ts
|
|
144
|
+
var mapTo = (cb) => (source) => cb(source);
|
|
145
|
+
|
|
143
146
|
// src/utility/dictionary/strArrayToDict.ts
|
|
144
147
|
function strArrayToDict(...strings) {
|
|
145
148
|
return strings.reduce((acc, str) => {
|
|
@@ -583,6 +586,7 @@ export {
|
|
|
583
586
|
kvToDict,
|
|
584
587
|
less,
|
|
585
588
|
literal,
|
|
589
|
+
mapTo,
|
|
586
590
|
mapValues,
|
|
587
591
|
nameLiteral,
|
|
588
592
|
or,
|
package/package.json
CHANGED