Add is.asyncFunction (#20)
This commit is contained in:
parent
04cb80dfb1
commit
dc3b6ff86b
3 changed files with 27 additions and 2 deletions
5
index.js
5
index.js
|
|
@ -85,7 +85,10 @@ is.promise = x => is.nativePromise(x) || hasPromiseAPI(x);
|
|||
is.generator = x => is.iterable(x) && is.function(x.next) && is.function(x.throw);
|
||||
|
||||
// TODO: Change to use `isObjectOfType` once Node.js 6 or higher is targeted
|
||||
is.generatorFunction = x => is.function(x) && is.function(x.constructor) && x.constructor.name === 'GeneratorFunction';
|
||||
const isFunctionOfType = type => x => is.function(x) && is.function(x.constructor) && x.constructor.name === type;
|
||||
|
||||
is.generatorFunction = isFunctionOfType('GeneratorFunction');
|
||||
is.asyncFunction = isFunctionOfType('AsyncFunction');
|
||||
|
||||
is.regExp = isObjectOfType('RegExp');
|
||||
is.date = isObjectOfType('Date');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue