inferred-types 0.28.5 → 0.29.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 +20 -3
- package/dist/index.js +7 -1
- package/dist/index.mjs +7 -1
- package/package.json +1 -1
- package/src/types/dictionary/MapTo.ts +23 -1
- package/src/utility/dictionary/mapTo.ts +24 -12
- package/tests/dictionary/mapTo.test.ts +14 -19
package/dist/index.d.ts
CHANGED
|
@@ -807,7 +807,7 @@ declare const mapToDict: MapperApi;
|
|
|
807
807
|
* const many2one = mapTo.manyToOne().map<I,O>( ... );
|
|
808
808
|
* ```
|
|
809
809
|
*/
|
|
810
|
-
declare const mapTo: (<I, O>(map: (source: I) => O[]) => <
|
|
810
|
+
declare const mapTo: (<I, O>(map: (source: I) => O[]) => Mapper<I, O, FinalizedMapConfig<"req", "I -> O[]", "opt">>) & MapperApi;
|
|
811
811
|
|
|
812
812
|
/**
|
|
813
813
|
* Expresses relationship between inputs/outputs:
|
|
@@ -873,7 +873,7 @@ declare type MapCardinalityConfig<IR extends OptRequired | undefined, OR extends
|
|
|
873
873
|
* method which allows the user configure the specifics of the mapping.
|
|
874
874
|
*/
|
|
875
875
|
declare type ConfiguredMap<C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = {
|
|
876
|
-
map: <I, O>(map: MapTo<I, O, C>) =>
|
|
876
|
+
map: <I, O>(map: MapTo<I, O, C>) => Mapper<I, O, C>;
|
|
877
877
|
input: MapIR<C>;
|
|
878
878
|
cardinality: MapCard<C>;
|
|
879
879
|
output: MapOR<C>;
|
|
@@ -970,6 +970,23 @@ declare type MapFnInput<I, IR extends OptRequired, D extends MapCardinalityIllus
|
|
|
970
970
|
* ```
|
|
971
971
|
*/
|
|
972
972
|
declare type MapFn<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = MapIR<C> extends "opt" ? <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(source?: S) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>> : <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(source: S) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>>;
|
|
973
|
+
/**
|
|
974
|
+
* **Mapper**
|
|
975
|
+
*
|
|
976
|
+
* A fully configured _mapper_ stemming from the **mapTo()** utility. It is both a mapping
|
|
977
|
+
* function and a dictionary which describes the mapper's properties.
|
|
978
|
+
* ```ts
|
|
979
|
+
* const m = mapTo.oneToOne().map( ... );
|
|
980
|
+
* const mapped = m(inputs);
|
|
981
|
+
* const mappedOver = inputs.map(m);
|
|
982
|
+
* ```
|
|
983
|
+
*/
|
|
984
|
+
declare type Mapper<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = {
|
|
985
|
+
input: MapIR<C>;
|
|
986
|
+
output: MapOR<C>;
|
|
987
|
+
cardinality: MapCard<C>;
|
|
988
|
+
debug: boolean | string;
|
|
989
|
+
} & MapFn<I, O, C>;
|
|
973
990
|
|
|
974
991
|
/**
|
|
975
992
|
* Given a dictionary of type `<T>`, this utility function will
|
|
@@ -2260,4 +2277,4 @@ interface IFluentConfigurator<C> {
|
|
|
2260
2277
|
*/
|
|
2261
2278
|
declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
|
|
2262
2279
|
|
|
2263
|
-
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AsFinalizedConfig, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, ConfiguredMap, Constructor, DEFAULT_MANY_TO_ONE_MAPPING, DEFAULT_ONE_TO_MANY_MAPPING, DEFAULT_ONE_TO_ONE_MAPPING, DashToSnake, DashUppercase, Dasherize, DecomposeMapConfig, DefaultManyToOneMapping, DefaultOneToManyMapping, DefaultOneToOneMapping, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, Extends, ExtendsClause, ExtendsNarrowlyClause, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FinalReturn, FinalizedMapConfig, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfBooleanLiteral, IfExtends, IfExtendsThen, IfLiteral, IfNumericLiteral, IfObject, IfOptionalLiteral, IfScalar, IfStringLiteral, Include, Includes, IntersectingKeys, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNumericLiteral, IsObject, IsOptionalLiteral, IsScalar, IsString, IsStringLiteral, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapCard, MapCardinality, MapCardinalityIllustrated, MapConfig, MapFn, MapFnInput, MapFnOutput, MapIR, MapInput, MapOR, MapOutput, MapTo, MapperApi, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, 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, StringFilter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefault, TypeDefinition, TypeGuard, TypeOptions, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
|
|
2280
|
+
export { AllCaps, Alpha, AlphaNumeric, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AsFinalizedConfig, AssertExtends, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, ConfiguredMap, Constructor, DEFAULT_MANY_TO_ONE_MAPPING, DEFAULT_ONE_TO_MANY_MAPPING, DEFAULT_ONE_TO_ONE_MAPPING, DashToSnake, DashUppercase, Dasherize, DecomposeMapConfig, DefaultManyToOneMapping, DefaultOneToManyMapping, DefaultOneToOneMapping, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DynamicRule, DynamicRuleSet, Email, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, Extends, ExtendsClause, ExtendsNarrowlyClause, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FinalReturn, FinalizedMapConfig, First, FirstKey, FirstKeyValue, FirstOfEach, FluentConfigurator, FluentFunction, FromDictArray, FunctionType, GeneralDictionary, Get, HasUppercase, IConfigurator, IFluentConfigurator, If, IfBooleanLiteral, IfExtends, IfExtendsThen, IfLiteral, IfNumericLiteral, IfObject, IfOptionalLiteral, IfScalar, IfStringLiteral, Include, Includes, IntersectingKeys, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNumericLiteral, IsObject, IsOptionalLiteral, IsScalar, IsString, IsStringLiteral, IsTrue, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapCard, MapCardinality, MapCardinalityIllustrated, MapConfig, MapFn, MapFnInput, MapFnOutput, MapIR, MapInput, MapOR, MapOutput, MapTo, Mapper, MapperApi, MaybeFalse, MaybeTrue, Model, Mutable, MutableProps, MutationFunction, MutationIdentity, Narrowable, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, 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, StringFilter, StringKeys, StringLength, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeCondition, TypeDefault, TypeDefinition, TypeGuard, TypeOptions, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, ValueTuple, ValueTypeFunc, ValueTypes, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, condition, createFnWithProps, createMutationFunction, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifTypeOf, isArray, isBoolean, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, randomString, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, uuid, valueTypes, withValue };
|
package/dist/index.js
CHANGED
|
@@ -627,7 +627,7 @@ And produced: ${JSON.stringify(
|
|
|
627
627
|
}
|
|
628
628
|
};
|
|
629
629
|
var mapper = (config) => (map) => {
|
|
630
|
-
|
|
630
|
+
const fn = (source) => {
|
|
631
631
|
const isArray2 = config.cardinality === "I -> O[]" && Array.isArray(source) ? true : config.cardinality === "I[] -> O" && Array.isArray(source) && Array.isArray(source[0]) ? true : false;
|
|
632
632
|
if (isArray2) {
|
|
633
633
|
const output = source.flatMap(map);
|
|
@@ -639,6 +639,12 @@ var mapper = (config) => (map) => {
|
|
|
639
639
|
return output;
|
|
640
640
|
}
|
|
641
641
|
};
|
|
642
|
+
return createFnWithProps(fn, {
|
|
643
|
+
input: config.input,
|
|
644
|
+
output: config.output,
|
|
645
|
+
cardinality: config.cardinality,
|
|
646
|
+
debug: config.debug
|
|
647
|
+
});
|
|
642
648
|
};
|
|
643
649
|
var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }, defaultValue) => ({
|
|
644
650
|
map: (source) => {
|
package/dist/index.mjs
CHANGED
|
@@ -536,7 +536,7 @@ And produced: ${JSON.stringify(
|
|
|
536
536
|
}
|
|
537
537
|
};
|
|
538
538
|
var mapper = (config) => (map) => {
|
|
539
|
-
|
|
539
|
+
const fn = (source) => {
|
|
540
540
|
const isArray2 = config.cardinality === "I -> O[]" && Array.isArray(source) ? true : config.cardinality === "I[] -> O" && Array.isArray(source) && Array.isArray(source[0]) ? true : false;
|
|
541
541
|
if (isArray2) {
|
|
542
542
|
const output = source.flatMap(map);
|
|
@@ -548,6 +548,12 @@ var mapper = (config) => (map) => {
|
|
|
548
548
|
return output;
|
|
549
549
|
}
|
|
550
550
|
};
|
|
551
|
+
return createFnWithProps(fn, {
|
|
552
|
+
input: config.input,
|
|
553
|
+
output: config.output,
|
|
554
|
+
cardinality: config.cardinality,
|
|
555
|
+
debug: config.debug
|
|
556
|
+
});
|
|
551
557
|
};
|
|
552
558
|
var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }, defaultValue) => ({
|
|
553
559
|
map: (source) => {
|
package/package.json
CHANGED
|
@@ -87,7 +87,7 @@ type MapCardinalityConfig<
|
|
|
87
87
|
export type ConfiguredMap<
|
|
88
88
|
C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
|
|
89
89
|
> = {
|
|
90
|
-
map: <I, O>(map: MapTo<I, O, C>) =>
|
|
90
|
+
map: <I, O>(map: MapTo<I, O, C>) => Mapper<I, O, C>;
|
|
91
91
|
input: MapIR<C>;
|
|
92
92
|
cardinality: MapCard<C>;
|
|
93
93
|
output: MapOR<C>;
|
|
@@ -361,3 +361,25 @@ export type MapFn<
|
|
|
361
361
|
: <S extends MapFnInput<I, MapIR<C>, MapCard<C>>>(
|
|
362
362
|
source: S
|
|
363
363
|
) => MapFnOutput<I, O, S, MapOR<C>, MapCard<C>>;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* **Mapper**
|
|
367
|
+
*
|
|
368
|
+
* A fully configured _mapper_ stemming from the **mapTo()** utility. It is both a mapping
|
|
369
|
+
* function and a dictionary which describes the mapper's properties.
|
|
370
|
+
* ```ts
|
|
371
|
+
* const m = mapTo.oneToOne().map( ... );
|
|
372
|
+
* const mapped = m(inputs);
|
|
373
|
+
* const mappedOver = inputs.map(m);
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
export type Mapper<
|
|
377
|
+
I,
|
|
378
|
+
O,
|
|
379
|
+
C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
|
|
380
|
+
> = {
|
|
381
|
+
input: MapIR<C>;
|
|
382
|
+
output: MapOR<C>;
|
|
383
|
+
cardinality: MapCard<C>;
|
|
384
|
+
debug: boolean | string;
|
|
385
|
+
} & MapFn<I, O, C>;
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FinalizedMapConfig,
|
|
3
3
|
MapCardinalityIllustrated,
|
|
4
|
-
MapFnInput,
|
|
5
4
|
MapperApi,
|
|
6
5
|
MapTo,
|
|
7
6
|
AsFinalizedConfig,
|
|
8
7
|
MapConfig,
|
|
9
8
|
ConfiguredMap,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
MapCard,
|
|
13
|
-
MapOR,
|
|
9
|
+
Mapper,
|
|
10
|
+
MapFn,
|
|
14
11
|
} from "src/types/dictionary";
|
|
15
12
|
import { OptRequired } from "src/types/literal-unions";
|
|
16
13
|
import { createFnWithProps } from "../createFnWithProps";
|
|
@@ -69,11 +66,18 @@ const debugMsg = <C extends FinalizedMapConfig<any, any, any>>(
|
|
|
69
66
|
* The single implementation for all mapping
|
|
70
67
|
*/
|
|
71
68
|
const mapper =
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
<
|
|
70
|
+
//
|
|
71
|
+
C extends FinalizedMapConfig<
|
|
72
|
+
OptRequired, //
|
|
73
|
+
MapCardinalityIllustrated,
|
|
74
|
+
OptRequired
|
|
75
|
+
>
|
|
76
|
+
>(
|
|
77
|
+
config: C
|
|
78
|
+
) =>
|
|
79
|
+
<I, O>(map: MapTo<I, O, C>): Mapper<I, O, C> => {
|
|
80
|
+
const fn: MapFn<I, O, C> = <S>(source: S) => {
|
|
77
81
|
/**
|
|
78
82
|
* Determine whether input is an array; this will be true
|
|
79
83
|
*/
|
|
@@ -93,18 +97,26 @@ const mapper =
|
|
|
93
97
|
// item and this approach achieves this.
|
|
94
98
|
// TODO: we should check that the approach below doesn't work for M:1 here
|
|
95
99
|
// as well
|
|
96
|
-
const output = (source as any).flatMap(map)
|
|
100
|
+
const output = (source as any).flatMap(map);
|
|
97
101
|
debugMsg(config, source, output);
|
|
98
102
|
|
|
99
103
|
return output;
|
|
100
104
|
} else {
|
|
101
105
|
// receive _all_ inputs provided as pass into ; this is just a single input unless the
|
|
102
106
|
// cardinality is
|
|
103
|
-
const output = map(source as any)
|
|
107
|
+
const output = map(source as any);
|
|
104
108
|
debugMsg(config, source, output);
|
|
109
|
+
|
|
105
110
|
return output;
|
|
106
111
|
}
|
|
107
112
|
};
|
|
113
|
+
|
|
114
|
+
return createFnWithProps(fn, {
|
|
115
|
+
input: config.input,
|
|
116
|
+
output: config.output,
|
|
117
|
+
cardinality: config.cardinality,
|
|
118
|
+
debug: config.debug,
|
|
119
|
+
});
|
|
108
120
|
};
|
|
109
121
|
|
|
110
122
|
/**
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
AsFinalizedConfig,
|
|
7
7
|
MapConfig,
|
|
8
8
|
ConfiguredMap,
|
|
9
|
+
Mapper,
|
|
9
10
|
} from "src/types/dictionary";
|
|
10
11
|
import { describe, expect, it } from "vitest";
|
|
11
12
|
import type { Expect, Equal } from "@type-challenges/utils";
|
|
@@ -169,37 +170,21 @@ describe("MapTo<I,O> and MapToFn<I,O>", () => {
|
|
|
169
170
|
// map() function's parameters (unknown is I)
|
|
170
171
|
Expect<Equal<[map: (source: unknown) => unknown], M1P>>,
|
|
171
172
|
// map() function's return value
|
|
172
|
-
Expect<
|
|
173
|
-
Equal<<S extends unknown>(source: S) => S extends unknown[] ? unknown[] : unknown, M1R>
|
|
174
|
-
>,
|
|
173
|
+
Expect<Equal<Mapper<unknown, unknown, FinalizedMapConfig<"req", "I -> O", "opt">>, M1R>>,
|
|
175
174
|
|
|
176
175
|
// merged configuration is same as default for M:1
|
|
177
176
|
Expect<Equal<C2, FinalizedMapConfig<"req", "I[] -> O", "req">>>,
|
|
178
177
|
// map() function's parameters (unknown is I)
|
|
179
178
|
Expect<Equal<[map: (source: unknown[]) => unknown], M2P>>,
|
|
180
179
|
// map() function's return value
|
|
181
|
-
Expect<
|
|
182
|
-
Equal<
|
|
183
|
-
<S extends unknown[] | unknown[][]>(
|
|
184
|
-
source: S
|
|
185
|
-
) => S extends unknown[][] ? [unknown, ...unknown[]] : unknown,
|
|
186
|
-
M2R
|
|
187
|
-
>
|
|
188
|
-
>,
|
|
180
|
+
Expect<Equal<Mapper<unknown, unknown, FinalizedMapConfig<"req", "I[] -> O", "req">>, M2R>>,
|
|
189
181
|
|
|
190
182
|
// merged configuration should be M:1 default with an "opt" for output
|
|
191
183
|
Expect<Equal<C3, FinalizedMapConfig<"req", "I[] -> O", "opt">>>,
|
|
192
184
|
// map() function's parameters (unknown is I)
|
|
193
185
|
Expect<Equal<[map: (source: unknown[]) => unknown | null], M3P>>,
|
|
194
186
|
// map() function's return value
|
|
195
|
-
Expect<
|
|
196
|
-
Equal<
|
|
197
|
-
<S extends unknown[] | unknown[][]>(
|
|
198
|
-
source: S
|
|
199
|
-
) => S extends unknown[][] ? unknown[] : unknown,
|
|
200
|
-
M3R
|
|
201
|
-
>
|
|
202
|
-
>
|
|
187
|
+
Expect<Equal<Mapper<unknown, unknown, FinalizedMapConfig<"req", "I[] -> O", "opt">>, M3R>>
|
|
203
188
|
];
|
|
204
189
|
|
|
205
190
|
const cases: cases = [true, true, true, true, true, true, true, true, true];
|
|
@@ -269,6 +254,16 @@ describe("mapTo() utility function", () => {
|
|
|
269
254
|
expect(c1.cardinality).toBe(MapCardinality.OneToMany);
|
|
270
255
|
});
|
|
271
256
|
|
|
257
|
+
it("Mapper<I,O,C>", () => {
|
|
258
|
+
const m0 = mapTo.oneToOne();
|
|
259
|
+
const m1 = m0.map<I, I>((i) => i);
|
|
260
|
+
|
|
261
|
+
expect(m1.input).toBe("req");
|
|
262
|
+
expect(m1.output).toBe("req");
|
|
263
|
+
expect(m1.cardinality).toBe("I -> O");
|
|
264
|
+
expect(m1(i)).toEqual(i);
|
|
265
|
+
});
|
|
266
|
+
|
|
272
267
|
it("M:1 conversion", () => {
|
|
273
268
|
const m = mapTo
|
|
274
269
|
.config({
|