From e69a4de1763ed4d8b2d60a84e25098a05c5eecda Mon Sep 17 00:00:00 2001 From: struct78 Date: Wed, 2 Aug 2017 14:25:22 +1000 Subject: [PATCH] Added undefined check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IE11 and below doesn’t support the name property of the constructor object, so put in a check to avoid exceptions when slice() method is called. --- browser.js | 4 ++-- index.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/browser.js b/browser.js index b6cf0c4..1b73969 100644 --- a/browser.js +++ b/browser.js @@ -30,7 +30,7 @@ module.exports = function kindOf(val) { // functions if (type === 'function' || val instanceof Function) { - if (val.constructor.name.slice(0, 9) === 'Generator') { + if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') { return 'generatorfunction'; } return 'function'; @@ -141,4 +141,4 @@ function isBuffer(val) { } },{}]},{},[1])(1) -}); \ No newline at end of file +}); diff --git a/index.js b/index.js index fe69c32..ce2c8b9 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,7 @@ module.exports = function kindOf(val) { // functions if (type === 'function' || val instanceof Function) { - if (val.constructor.name.slice(0, 9) === 'Generator') { + if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') { return 'generatorfunction'; } return 'function';