Add is.TupleLike#156

This commit is contained in:
Tal Mac 2023-07-21 23:58:17 +03:00
parent 94dc715577
commit a04c656ec7
3 changed files with 70 additions and 0 deletions

View file

@ -410,6 +410,23 @@ 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
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.