Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added undefined check #14

Merged
merged 1 commit into from Aug 2, 2017
Merged

Conversation

struct78
Copy link

@struct78 struct78 commented Aug 2, 2017

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.

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.
@jonschlinkert jonschlinkert merged commit b827fd5 into jonschlinkert:master Aug 2, 2017
@@ -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') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when so much bytes is used, it's probably better to directly be checking of string.

So:

var name = (val.constructor && val.constructor.name) || ''
if (name && name.length && name.slice(0, 9) === 'Generator') {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially, i just meant that if (typeof val.constructor.name === 'string' && would be better, but later update my thought :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants