https://github.com/robusgauli/humanize-bool
Intuitive Boolean expression evaluator
https://github.com/robusgauli/humanize-bool
boolean-expression boolean-logic boolean-query query-language
Last synced: 4 months ago
JSON representation
Intuitive Boolean expression evaluator
- Host: GitHub
- URL: https://github.com/robusgauli/humanize-bool
- Owner: RobusGauli
- License: mit
- Created: 2019-01-02T16:34:21.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-13T16:26:41.000Z (over 6 years ago)
- Last Synced: 2025-02-02T22:26:08.675Z (5 months ago)
- Topics: boolean-expression, boolean-logic, boolean-query, query-language
- Language: JavaScript
- Homepage:
- Size: 400 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Boolean Expression Evaluator for humans
## Installation
```unix
// From NPM
npm install humanize-bool --save
``````unix
// From Yarn
yarn add humanize-bool
```## Usage
```javascript
import is from 'humanize-bool';
```## Examples
```javascript
// Beforeif (val === 'cat' || val === 'dog' || val === 'car' || val === 'home') {
// code here ...
}// After
if (is(val).any.equalsTo('cat', 'dog', 'car', 'home')) {
// code here
}```
```javascript
// Beforeif (val === undefined || value === null) {
// code here ...
}// After
if (is(val).undefined.or.null()) {
// code here
}```
```javascript
// Beforeif (typeof val === null || typeof val === 'function') {
// code here ...
}// After
if (is(val).type.null.or.func()) {
// code here
}```
```javascript
// Beforeif (typeof val === 'string' || typeof val === 'number' || typeof val === 'symbol') {
// code here ...
}// After
if (is(val).type.string.or.number.or.symbol()) {
// code here
}// OR
if (is(val).type.any('string', 'number', 'symbol')) {
// code here
}
```