Add is.asyncFunction

This commit is contained in:
Brandon Smith 2017-10-15 19:16:38 -04:00
parent 04cb80dfb1
commit 3a2dc4bd3b
3 changed files with 27 additions and 2 deletions

View file

@ -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');