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 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`; where:
1476
+ * A utility function which maps one dictionary structure `I` to another `O`; which allows
1477
+ * the transform to:
1477
1478
  *
1478
- * - `I` maps to `O[ ]` so this allows a cardinality of 0:M
1479
- * - In other words ... values from `I` can be filtered, translated 1:1 or split into multiple outputs
1480
- * - Type constrains laid out by `I` and `O` will be enforced by type system
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
- * type I = { title: string; color: string; products: Product[] };
1484
- * type O = { title: string; count: number };
1485
- * const summarize: mapTo<I,O>()
1486
- * .map();
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -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`; where:
6
+ * A utility function which maps one dictionary structure `I` to another `O`; which allows
7
+ * the transform to:
7
8
  *
8
- * - `I` maps to `O[ ]` so this allows a cardinality of 0:M
9
- * - In other words ... values from `I` can be filtered, translated 1:1 or split into multiple outputs
10
- * - Type constrains laid out by `I` and `O` will be enforced by type system
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
- * type I = { title: string; color: string; products: Product[] };
14
- * type O = { title: string; count: number };
15
- * const summarize: mapTo<I,O>()
16
- * .map();
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 =