inversify-string-mapper
v1.0.1
Published
string mapper definitions
Readme
inversify-string-mapper
inversify string mapper utility
install dependencies
npm installbuild
npm run buildtest
npm testtest with coverage report
npm run test:coveragemutation test
npm run test:mutationformat
npm run formatInstall into project
npm install inversify-string-mapperHow to use
Load the module.
...
import { StringMapperModule } from "inversify-string-mapper";
...
export const container = (): Container => {
const container = new Container();
container.load(new StringMapperModule());
return container;
};Inject the interface by type.
...
import { STRING_MAPPER_TYPE, StringMapperInterface } from "inversify-string-mapper";
...
@inject(STRING_MAPPER_TYPE.StringMapper)
private readonly stringMapper: StringMapperInterfaceUse the mapper.
...
stringMapper.mapper('value'); // return 'value'
stringMapper.mapper(null); // return ''
stringMapper.mapper(null, 'default'); // return 'default'
stringMapper.mapper(' value '); // return 'value'
stringMapper.mapper(5); // return '5'
...
