inferred-types 0.24.2 → 0.24.3
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 +17 -8
- package/package.json +1 -1
- package/src/utility/dictionary/mapTo.ts +17 -8
package/dist/index.d.ts
CHANGED
|
@@ -1473,17 +1473,26 @@ declare function mapValues<N extends Narrowable, T extends Record<string, N>, V>
|
|
|
1473
1473
|
/**
|
|
1474
1474
|
* **mapTo**
|
|
1475
1475
|
*
|
|
1476
|
-
* A utility function which maps one dictionary structure `I` to another `O`;
|
|
1476
|
+
* A utility function which maps one dictionary structure `I` to another `O`; which allows
|
|
1477
|
+
* the transform to:
|
|
1477
1478
|
*
|
|
1478
|
-
* -
|
|
1479
|
-
* -
|
|
1480
|
-
* -
|
|
1479
|
+
* - _split_ inputs into multiple outputs
|
|
1480
|
+
* - _map_ 1:1 between input and output
|
|
1481
|
+
* - _filter_ inputs which don't meet certain criteria (by returning `null`)
|
|
1481
1482
|
*
|
|
1483
|
+
* This higher order function first asks for the mapping criteria:
|
|
1482
1484
|
* ```ts
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1485
|
+
* const mapper = mapTo<I,O>(i => i.name
|
|
1486
|
+
* ? [
|
|
1487
|
+
* { name: i.name, a: "static text", b: i.products.length }
|
|
1488
|
+
* ]
|
|
1489
|
+
* : null
|
|
1490
|
+
* );
|
|
1491
|
+
* ```
|
|
1492
|
+
*
|
|
1493
|
+
* and now you'll have a _mapper_ variable will be assigned as a mapping fn:
|
|
1494
|
+
* ```ts
|
|
1495
|
+
* function (source: I | I[]): O[]
|
|
1487
1496
|
* ```
|
|
1488
1497
|
*/
|
|
1489
1498
|
declare const mapTo: <I extends {}, O extends {}>(cb: MapToWithFiltering<I, O>) => (source: I | I[]) => O[];
|
package/package.json
CHANGED
|
@@ -3,17 +3,26 @@ import { MapToWithFiltering } from "src/types/dictionary";
|
|
|
3
3
|
/**
|
|
4
4
|
* **mapTo**
|
|
5
5
|
*
|
|
6
|
-
* A utility function which maps one dictionary structure `I` to another `O`;
|
|
6
|
+
* A utility function which maps one dictionary structure `I` to another `O`; which allows
|
|
7
|
+
* the transform to:
|
|
7
8
|
*
|
|
8
|
-
* -
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
9
|
+
* - _split_ inputs into multiple outputs
|
|
10
|
+
* - _map_ 1:1 between input and output
|
|
11
|
+
* - _filter_ inputs which don't meet certain criteria (by returning `null`)
|
|
11
12
|
*
|
|
13
|
+
* This higher order function first asks for the mapping criteria:
|
|
12
14
|
* ```ts
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* const mapper = mapTo<I,O>(i => i.name
|
|
16
|
+
* ? [
|
|
17
|
+
* { name: i.name, a: "static text", b: i.products.length }
|
|
18
|
+
* ]
|
|
19
|
+
* : null
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* and now you'll have a _mapper_ variable will be assigned as a mapping fn:
|
|
24
|
+
* ```ts
|
|
25
|
+
* function (source: I | I[]): O[]
|
|
17
26
|
* ```
|
|
18
27
|
*/
|
|
19
28
|
export const mapTo =
|