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

there is something unsuitable about isGenerator and isObject function #314

Open
waterVenice7 opened this issue Mar 3, 2017 · 2 comments

Comments

@waterVenice7
Copy link

function isGenerator(obj) {
  return 'function' == typeof obj.next && 'function' == typeof obj.throw;
}

why not use toString.call(obj)==="[object Generator]" to replace that?
I think this is a more definite judge solution than default way;

function isObject(val) {
  return Object == val.constructor;
}

val.constrctor could be rewrited, I suggest that we can use toString.call(val)==="[object Object]" to get a more explicit check;

@jsdevtom
Copy link

When yielding {} in a generator, I get this message because the isObject function isn't more robust

TypeError: You may only yield a function, promise, generator, array, or object, but the following object was passed: "[object Object]"

isObject, according to the most upvoted stackoverflow post should be:

return typeof yourVariable === 'object' && yourVariable !== null

@jsdevtom
Copy link

Please label as Bug

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

No branches or pull requests

2 participants