https://github.com/varbrad/is-any
https://github.com/varbrad/is-any
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/varbrad/is-any
- Owner: varbrad
- License: mit
- Created: 2018-07-14T21:10:58.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-14T23:06:36.000Z (about 7 years ago)
- Last Synced: 2025-02-17T14:50:02.882Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/is-any
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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
```javascript
var isAny = require('is-any');var d = 50
isAny(d, 20, 40, 60) // false
isAny(d, 30, 50, 70) // true
```ES6
```javascript
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;
```javascript
if (value === 20 || value === 25 || value === 60) {
// do something
}
```After;
```javascript
if (isAny(value, 20, 25, 60)) {
// do something
}
```