added is.class based on es6 class implementation
This commit is contained in:
parent
103c5afe6f
commit
0a06209d05
2 changed files with 10 additions and 1 deletions
3
index.js
3
index.js
|
|
@ -62,6 +62,7 @@ is.symbol = x => typeof x === 'symbol';
|
|||
|
||||
is.array = Array.isArray;
|
||||
is.function = x => typeof x === 'function';
|
||||
is.class = x => typeof x === 'function' && /^\s*class\s+/.test(x.toString());
|
||||
is.buffer = Buffer.isBuffer;
|
||||
|
||||
is.object = x => {
|
||||
|
|
@ -130,7 +131,7 @@ is.plainObject = x => {
|
|||
// eslint-disable-next-line no-return-assign
|
||||
return getObjectType(x) === 'Object' &&
|
||||
(prototype = Object.getPrototypeOf(x), prototype === null ||
|
||||
prototype === Object.getPrototypeOf({}));
|
||||
prototype === Object.getPrototypeOf({}));
|
||||
};
|
||||
|
||||
is.iterable = x => !is.null(x) && !is.undefined(x) && typeof x[Symbol.iterator] === 'function';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue