forked from orbit-oss/is
Add .tupleLike() (#189)
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
This commit is contained in:
parent
94dc715577
commit
3868f47783
4 changed files with 119 additions and 1 deletions
20
readme.md
20
readme.md
|
|
@ -410,6 +410,26 @@ function foo() {
|
|||
foo();
|
||||
```
|
||||
|
||||
##### .tupleLike(value, guards)
|
||||
|
||||
A `value` is tuple-like if it matches the provided `guards` array both in `.length` and in types.
|
||||
|
||||
```js
|
||||
is.tupleLike([1], [is.number]);
|
||||
//=> true
|
||||
```
|
||||
|
||||
```js
|
||||
function foo() {
|
||||
const tuple = [1, '2', true];
|
||||
if (is.tupleLike(tuple, [is.number, is.string, is.boolean])) {
|
||||
tuple // [number, string, boolean]
|
||||
}
|
||||
}
|
||||
|
||||
foo();
|
||||
```
|
||||
|
||||
#### .positiveNumber(value)
|
||||
|
||||
Check if `value` is a number and is more than 0.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue