@why-exits/boolean
v1.0.2
Published
Over-engineered boolean parser with comprehensive type guards, converters, and validators
Maintainers
Readme
@why-exits/boolean
Installation
npm install @why-exits/booleanUsage
import { parseBoolean } from '@why-exits/boolean';
parseBoolean(true); // true
parseBoolean('yes'); // true
parseBoolean(1); // true
parseBoolean(0); // false
parseBoolean(null); // false
parseBoolean('false'); // falseModular Imports
Import specific modules for tree-shaking:
import { isBoolean, isString } from '@why-exits/boolean/type-guards';
import { convertNumberToBoolean } from '@why-exits/boolean/converters';
import { isStringTruthy } from '@why-exits/boolean/validators';
import { normalizeStringValue } from '@why-exits/boolean/utils';Supported Values
Truthy Values
true'true','yes','1','on','y','t'(case-insensitive)- Non-zero numbers
Falsy Values
false'false','no','0','off','n','f',''(case-insensitive)0null,undefined
License
MIT
