is-any
v1.1.0
Published
Simple OR equality checker
Downloads
2
Readme
Simple alternative to large or
chains in your code.
Installation
Using npm
or yarn
.
npm install is-any
yarn add is-any
Usage
CommonJS
var isAny = require('is-any');
var d = 50
isAny(d, 20, 40, 60) // false
isAny(d, 30, 50, 70) // true
ES6
import isAny from 'is-any';
const d = 60
isAny(d, 1, 2, 3) // false
isAny(d, 5, 9, 44, 28, 60, 23, 44, 11) // true
Why?
Before;
if (value === 20 || value === 25 || value === 60) {
// do something
}
After;
if (isAny(value, 20, 25, 60)) {
// do something
}