Add is.generator() and is.generatorFunction() (#4)
This commit is contained in:
parent
000f66bbdc
commit
dbe5cc8d82
3 changed files with 26 additions and 1 deletions
5
index.js
5
index.js
|
|
@ -82,6 +82,11 @@ const hasPromiseAPI = x =>
|
|||
|
||||
is.promise = x => is.nativePromise(x) || hasPromiseAPI(x);
|
||||
|
||||
is.generator = x => is.iterable(x) && is.function(x.next) && is.function(x.throw);
|
||||
|
||||
// Change to use `isObjectOfType` once Node 4.x.x LTS is dropped
|
||||
is.generatorFunction = x => x.constructor.name === 'GeneratorFunction';
|
||||
|
||||
is.regExp = isObjectOfType('RegExp');
|
||||
is.date = isObjectOfType('Date');
|
||||
is.error = isObjectOfType('Error');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue