inversify-boolean-mapper
v1.0.0
Published
boolean mapper definitions
Downloads
4
Readme
inversify-boolean-mapper
inversify boolean 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-boolean-mapper
How to use
Load the module.
...
import { BooleanMapperModule } from "inversify-boolean-mapper";
...
export const container = (): Container => {
const container = new Container();
container.load(new BooleanMapperModule());
return container;
};
Inject the interface by type.
...
import { BOOLEAN_MAPPER_TYPE, BooleanMapperInterface } from "inversify-boolean-mapper";
...
@inject(BOOLEAN_MAPPER_TYPE.BooleanMapper)
private readonly booleanMapper: BooleanMapperInterface
Use the mapper.
...
booleanMapper.mapper('yes'); // return true
booleanMapper.mapper('oui'); // return true
booleanMapper.mapper('si'); // return true
booleanMapper.mapper('True'); // return true
booleanMapper.mapper('tRuE'); // return true
booleanMapper.mapper(true); // return true
booleanMapper.mapper('False'); // return false
booleanMapper.mapper('faLsE'); // return false
booleanMapper.mapper(false); // return false
booleanMapper.mapper(null); // return false
booleanMapper.mapper(null, true); // return true
booleanMapper.mapper(null, false); // return false
booleanMapper.mapper(' '); // return false
booleanMapper.mapper('abcd'); // return false
...