Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Maintainers
4
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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc