Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Force Boolean

Greenkeeper badge Build Status

Forced transform your variable into a boolean without worried.

How to install

  • via npm: npm install --save force-boolean
  • via yarn: yarn add force-boolean

How to use

// ES6+ Babel
import ForceBoolean from 'force-boolean'
// Typescript
import ForceBoolean from 'force-boolean'
// CommonJS
const ForceBoolean = require('force-boolean').default

const YOUR_VAR = 'false'
console.log(ForceBoolean(YOUR_VAR)) // it's return boolean false

Test

  • return false if value is number 0
  • return false if value is string '0'
  • return false if value is string 'false'
  • return false if value is boolean false
  • return false if value is undefined
  • return false if value is null
  • return true if value is number 1
  • return true if value is string '1'
  • return true if value is string 'true'
  • return true if value is boolean true

About

🔨 Forced transform your variable into a boolean without worried.

Topics

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages