🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

boobool

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boobool

Convert a boolean from a string, keeping undefined and null values, to be able to use defaultsTo

1.0.1
latest
Source
npm
Version published
Weekly downloads
121
-48.95%
Maintainers
4
Weekly downloads
 
Created
Source

boobool NPM Version Build Status

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');  //-> true
boobool(' TRUE ');  //-> true
boobool('false');  //-> false

boobool('yes');  //-> undefined
boobool('1');  //-> undefined
boobool('');  //-> undefined
boobool(null);  //-> undefined
boobool(undefined);  //-> undefined

Optionally, you can override the default value:

boobool('', {defaultValue: true});  //-> true

FAQs

Package last updated on 03 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts