Add is.empty()
This commit is contained in:
parent
ee8f5d16f8
commit
af2ad0c819
3 changed files with 36 additions and 0 deletions
8
index.js
8
index.js
|
|
@ -163,4 +163,12 @@ is.inRange = (x, range) => {
|
|||
|
||||
is.infinite = x => x === Infinity || x === -Infinity;
|
||||
|
||||
is.empty = value => {
|
||||
return (
|
||||
((is.string(value) || is.array(value)) && !value.length) ||
|
||||
(!is.map(value) && !is.set(value) && is.object(value) && !Object.keys(value).length) ||
|
||||
((is.map(value) || is.set(value)) && !value.size)
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = is;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue