Clean up #4
This commit is contained in:
parent
dbe5cc8d82
commit
226e4d90da
2 changed files with 9 additions and 9 deletions
4
index.js
4
index.js
|
|
@ -84,8 +84,8 @@ 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';
|
||||
// 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';
|
||||
|
||||
is.regExp = isObjectOfType('RegExp');
|
||||
is.date = isObjectOfType('Date');
|
||||
|
|
|
|||
14
test.js
14
test.js
|
|
@ -59,8 +59,11 @@ const types = new Map([
|
|||
]],
|
||||
['promise', {then() {}, catch() {}}],
|
||||
['generator', (function * () {
|
||||
yield 42;
|
||||
yield 4;
|
||||
})()],
|
||||
['generatorFunction', function * () {
|
||||
yield 4;
|
||||
}],
|
||||
['map', new Map()],
|
||||
['set', new Set()],
|
||||
['weakMap', new WeakMap()],
|
||||
|
|
@ -138,7 +141,7 @@ test('is.array', t => {
|
|||
});
|
||||
|
||||
test('is.function', t => {
|
||||
testType(t, 'function');
|
||||
testType(t, 'function', ['generatorFunction']);
|
||||
});
|
||||
|
||||
test('is.buffer', t => {
|
||||
|
|
@ -174,14 +177,11 @@ if (isNode8orHigher) {
|
|||
}
|
||||
|
||||
test('is.generator', t => {
|
||||
testType(t, 'generator', ['function']);
|
||||
testType(t, 'generator');
|
||||
});
|
||||
|
||||
test('is.generatorFunction', t => {
|
||||
const gen = function * () {
|
||||
yield 42;
|
||||
};
|
||||
t.true(m.generatorFunction(gen));
|
||||
testType(t, 'generatorFunction', ['function']);
|
||||
});
|
||||
|
||||
test('is.map', t => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue