Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

str2bool

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

str2bool

Converts a string or number like boolean to true / false of type boolean.

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
decreased by-4.55%
Maintainers
1
Weekly downloads
 
Created
Source

str2bool

Map data like boolean to true / false of type boolean

类型和值修改为
"true" (String)true(boolean)
"false" (String)false(boolean)
true (boolean)true(boolean)
false (boolean)false(boolean)
"1" (String)true(boolean)
"0" (String)false(boolean)
1 (int)true(boolean)
0 (int)false(boolean)

install

npm install str2bool --save

test

npm test

Usage

const str2bool = require('str2bool');

console.log(str2bool(true)); // true
console.log(str2bool('true')); // true
console.log(str2bool(1)); // true
console.log(str2bool('1')); // true

console.log(str2bool(false)); // false
console.log(str2bool('false')); // fasle
console.log(str2bool(0)); // false
console.log(str2bool('0')); // false

console.log(str2bool('true ')); // false
console.log(str2bool(223)); // false
console.log(str2bool('223')); // false
console.log(str2bool('')); // false
console.log(str2bool(' ')); // false
console.log(str2bool()); // false

Keywords

FAQs

Package last updated on 14 Jan 2018

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