inversify-number-mapper
v1.0.1
Published
number mapper definitions
Downloads
9
Readme
inversify-number-mapper
inversify number mapper utility
install dependencies
npm install
build
npm run build
test
npm test
test with coverage report
npm run test:coverage
mutation test
npm run test:mutation
format
npm run format
Install into project
npm install inversify-number-mapper
How to use
Load the module.
...
import { NumberMapperModule } from "inversify-number-mapper";
...
export const container = (): Container => {
const container = new Container();
container.load(new NumberMapperModule());
return container;
};
Inject the interface by type.
...
import { NUMBER_MAPPER_TYPE, NumberMapperInterface } from "inversify-number-mapper";
...
@inject(NUMBER_MAPPER_TYPE.NumberMapper)
private readonly numberMapper: NumberMapperInterface
Use the mapper.
...
numberMapper.mapper('value'); // return 0
numberMapper.mapper(null); // return 0
numberMapper.mapper(null, 10); // return 10
numberMapper.mapper(' 5 '); // return 5
numberMapper.mapper(5); // return 5
...