package
Parse a string representation of a boolean.
npm install parse-string-booleanGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 7 packages.
146.5 kB
Includes dependencies.
Parse a string representation of a boolean.
truefalsenull (customizable) if the string does not represent a booleanNode.js >= 6 is required. To install, type this at the command line:
npm install parse-string-booleanparseBoolean(string[, defaultValue])
const parseBoolean = require('parse-string-boolean');
parseBoolean('true'); //-> true
parseBoolean(' TRUE '); //-> true
parseBoolean('false'); //-> false
parseBoolean('yes'); //-> null
parseBoolean('1'); //-> null
parseBoolean(''); //-> nullOptionally, you can override the default value for strings that do not represent a boolean:
parseBoolean('', true); //-> true