Skip to content

Commit

Permalink
Merge pull request #8 from tunnckoCore/master
Browse files Browse the repository at this point in the history
feat(promise): add promise kind and tests
  • Loading branch information
jonschlinkert committed May 19, 2017
2 parents 0ffe67c + 971e507 commit e4317b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions browser.js
Expand Up @@ -60,6 +60,9 @@ module.exports = function kindOf(val) {
if (type === '[object Error]') {
return 'error';
}
if (type === '[object Promise]') {
return 'promise';
}

// buffer
if (isBuffer(val)) {
Expand Down
3 changes: 3 additions & 0 deletions index.js
Expand Up @@ -59,6 +59,9 @@ module.exports = function kindOf(val) {
if (type === '[object Error]') {
return 'error';
}
if (type === '[object Promise]') {
return 'promise';
}

// buffer
if (isBuffer(val)) {
Expand Down
11 changes: 11 additions & 0 deletions test/es6/index.js
Expand Up @@ -6,6 +6,17 @@ var kindOf = require('../..');

module.exports = function() {
describe('es6 features', function() {
it('should work for resolved promises', function() {
var promise = Promise.resolve(123);
assert.strictEqual(kindOf(promise), 'promise');
});

it('should work for rejected promises', function() {
var promise = Promise.reject(new Error('foo bar'));
promise.catch(function() {})
assert.strictEqual(kindOf(promise), 'promise');
});

it('should work for generators', function() {
var gen = function * named() {return true;};
assert.equal(kindOf(gen), 'function');
Expand Down

0 comments on commit e4317b3

Please sign in to comment.