-
Notifications
You must be signed in to change notification settings - Fork 6
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
More robust get constructor name #11
More robust get constructor name #11
Conversation
We really need to extract this into it's own module 😸 |
Yeah I feel like if we're going to this much effort to fix this up, let's push it into a separate mini-module. Otherwise though, good changes! |
@lucasfcosta I've created https://github.com/chaijs/get-function-name, if you would like to create a PR to that repo, that'd be swell. Otherwise if I get some time tonight, I'll do it. |
@keithamus Yes! Great idea. |
I'm moving this there. But let get this merged anyway since it has changes to EDIT: This is done. Let's merge chaijs/get-func-name#1 and generate saucelabs tokens for release. |
LGTM |
Can't we merge only #12 and close this? |
Yup either way works. Edit: Yeah, let's close this one and merge the other; the commits don't have the same hash id. |
Depends on #9.
Due to chaijs/chai#813 tests in this module started failing because of poorly constructed errors (chaijs/chai#45).
This change also improves detection to whether we've got to run the polyfill or not, because if something already has a
.name
we can get it instantly.Also, the new
if
clause insidegetConstructorName
guarantees we will be using the result ofgetFunctionName(new errorLike())
only when it's useful, otherwise the empty string is correct, since we're dealing with an anonymous function.This was the most concise and simplest way me and @vieiralucas could get to a solution.
Also, special thanks to him for pairing with me to solve this 😄
PS.: WORKS ON IE 😎