boobool

Convert a boolean from a string, keeping undefined and null values
- Parses "true" as
true
- Parses "false" as
false
- Case-insensitive
- Ignores leading and trailing whitespace
- Parses
undefined
and null
as undefined
- Returns
undefined
when a boolean could not be found
- Configurable
defaultValue
(replaces undefined
)
Installation
npm install boobool
Usage
parseBoolean(string[, {defaultValue}])
const boobool = require('boobool');
boobool('true');
boobool(' TRUE ');
boobool('false');
boobool('yes');
boobool('1');
boobool('');
boobool(null);
boobool(undefined);
Optionally, you can override the default value:
boobool('', {defaultValue: true});