diff --git a/browser.js b/browser.js index e0ea787..b62043c 100644 --- a/browser.js +++ b/browser.js @@ -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)) { diff --git a/index.js b/index.js index b52c291..4c0233b 100644 --- a/index.js +++ b/index.js @@ -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)) { diff --git a/test/es6/index.js b/test/es6/index.js index 96bc93c..b074eec 100644 --- a/test/es6/index.js +++ b/test/es6/index.js @@ -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');