This repository was archived by the owner on Jul 20, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export class DataMapperChain {
3838
3939 /**
4040 * Create a new instance of a DataMapperChain.
41- * @param param0 DataMapperChain configuration object @see IDataMapperChainConfig
41+ * @param __namedParameters DataMapperChain configuration object
4242 */
4343 constructor ( {
4444 mappers = [ ] ,
Original file line number Diff line number Diff line change 1+ ### Initialization and configuration
2+ ``` ts
3+
4+ import { DataMapperChain } from " @exploratoryengineering/data-mapper-chain" ;
5+
6+ // Optional config
7+ const myMapper = new DataMapperChain ();
8+
9+ // With config
10+ const myMapperWithConfig = new DataMapperChain ({
11+ mappers: [],
12+ name: " My name for the mapper" ,
13+ });
14+
15+ ```
16+
17+ ### Adding mappers
18+
19+ #### Using short hand
20+ ``` ts
21+ import { DataMapperChain } from " @exploratoryengineering/data-mapper-chain" ;
22+
23+ // Create mapper and add mappers
24+ const dataMapperChain = new DataMapperChain ()
25+ .chunk ({
26+ start: 50 ,
27+ size: 4 ,
28+ })
29+ .hexToInt ();
30+
31+ ```
32+
33+
34+ ### Mapping data
35+ ``` ts
36+ // Create mapper and add mappers
37+ const dataMapperChain = new DataMapperChain ()
38+ .chunk ({
39+ start: 50 ,
40+ size: 4 ,
41+ })
42+ .hexToInt ();
43+
44+ const deviceData: string = ` 47eee3803e3a8c713f8daf7242fc6666423c28c04111d84000024b00a3030c261b010b91d3 ` ;
45+ // Create data object (coincidentally the value is CO2 ppm)
46+ const data: IDataValue = {
47+ name: " CO2 ppm" ,
48+ value: deviceData ,
49+ };
50+
51+ // Run mapper
52+ dataMapperChain .mapData (data ); // prints { name: 'CO2 ppm', value: 587 }
53+ ```
You can’t perform that action at this time.
0 commit comments