https://github.com/rohmanhm/force-boolean
🔨 Forced transform your variable into a boolean without worried.
https://github.com/rohmanhm/force-boolean
boolean javascript library transform
Last synced: 9 months ago
JSON representation
🔨 Forced transform your variable into a boolean without worried.
- Host: GitHub
- URL: https://github.com/rohmanhm/force-boolean
- Owner: rohmanhm
- License: mit
- Created: 2017-02-09T11:47:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:40:56.000Z (about 3 years ago)
- Last Synced: 2025-03-05T14:03:33.958Z (11 months ago)
- Topics: boolean, javascript, library, transform
- Language: TypeScript
- Homepage:
- Size: 1.02 MB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Force Boolean
[](https://greenkeeper.io/)
[](https://travis-ci.org/rohmanhm/force-boolean)
> 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
```javascript
// 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
- [x] return false if value is number 0
- [x] return false if value is string '0'
- [x] return false if value is string 'false'
- [x] return false if value is boolean false
- [x] return false if value is undefined
- [x] return false if value is null
- [x] return true if value is number 1
- [x] return true if value is string '1'
- [x] return true if value is string 'true'
- [x] return true if value is boolean true