Create a new instance of a DataMapperChain.
DataMapperChain configuration object
The initial mappers for the DataMapperChain
The initial meta data for the DataMapperChain
The initial name for the DataMapperChain
Add a mapper to the DataMapperChain.
Mapper to be added
Make a new mapper type available to the DataMapperChain. If the mapper type already exists it will be overwritten.
Mappertype to be added
Add a Base64 mapper
Configuration for the Base64 mapper
Add a Chunk mapper
Configuration for the Chunk mapper
Create a IMapper based on the given IMapperConfig. If no mapper type is found the function returns false.
The IMapperConfig for the mapper
Helper function to find a mapper in available mappers.
Mapper ID as string
Add a FromJSON mapper
Configuration for the FromJSON mapper
Add a HexToFloat mapper
Configuration for the HexToFloat mapper
Add a HexToInt mapper
Configuration for the HexToInt mapper
Loads a configuration which has been exported earlier by serializeConfig.
Configuration string as exported from serializeConfig @see serializeConfig
Uses the configured mappers for the DataMapperChain and maps the given data through the mappers.
Add a Offset mapper
Configuration for the Offset mapper
Serializes the DataMapperChain configuration including the mappers added to the chain. Returns a string representation of the configuration which has been run through JSON.stringify.
Generated using TypeDoc
DataMapperChain is a simple collection of mappers and allows for serializing and loading configurations of mappers.
Initialization and configuration
import { DataMapperChain } from "@exploratoryengineering/data-mapper-chain"; // Optional config const myMapper = new DataMapperChain(); // With config const myMapperWithConfig = new DataMapperChain({ mappers: [], name: "My name for the mapper", });
Adding mappers
Using short hand
import { DataMapperChain } from "@exploratoryengineering/data-mapper-chain"; // Create mapper and add mappers const dataMapperChain = new DataMapperChain() .chunk({ start: 50, size: 4, }) .hexToInt();
Mapping data
// Create mapper and add mappers const dataMapperChain = new DataMapperChain() .chunk({ start: 50, size: 4, }) .hexToInt(); const deviceData: string = `47eee3803e3a8c713f8daf7242fc6666423c28c04111d84000024b00a3030c261b010b91d3`; // Run mapper dataMapperChain.mapData(deviceData); // prints 587