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

Fixed identifier of bound functions on node 4 #9

Closed
wants to merge 4 commits into from

Conversation

jordaaash
Copy link
Contributor

Originally detected while using co-redis; thenify breaks libraries that depend on it when using Node 4.x and bound functions are passed to eval/createWrapper.

This is because the function name 'bound ' contains a space, making it an illegal identifier.

This commit fixes this in accordance with the same fix here.

@jonathanong
Copy link
Contributor

can you add a test?

This is a test for ae45c93

It tests that an anonymous bound function has no name when `thenify`'d (default in node 0.12.x, patched by ae45c93 for node 4.x). It also verifies that a named function `bound` is still named `bound` when `thenify`'d.
@jordaaash
Copy link
Contributor Author

There seems to be a problem with Travis relating to Node 0.8, but here is the test output after all commits in this PR:

➜  thenify git:(patch-1) node -v
v4.2.1
➜  thenify git:(patch-1) npm -v
2.14.7
➜  thenify git:(patch-1) npm test

> thenify@3.1.0 test /Users/jordan/Projects/thenify
> mocha --reporter spec



  ✓ fn.name
  ✓ fn.name (bound function)
  ✓ fn(callback(err))
  ✓ fn(callback(null, value))
  ✓ fn(callback(null, values...))
  ✓ fn(..args, callback())
  Promisify
    ✓ should reject errors
    ✓ should reject errors with arguments
    ✓ should return the result

  with callback backward compatible
    fn.name
      ✓ should set function name by default
      ✓ should set name to empty
    fn(callback(err)
      ✓ promise
      ✓ callback
    fn(callback(null, value))
      ✓ promise
      ✓ callback
    fn(callback(null, values...))
      ✓ promise
      ✓ callback
    fn(..args, callback())
      ✓ promise
      ✓ callback


  19 passing (25ms)

@jonathanong
Copy link
Contributor

oh feel free to remove 0.8 from travis. we don't need to support it anymore.

@jordaaash
Copy link
Contributor Author

Not sure how you like commits structured, but I can squash these if desired.

@jonathanong
Copy link
Contributor

nope these are great because your commits names all make sense 👍

jonathanong pushed a commit that referenced this pull request Oct 20, 2015
@jonathanong
Copy link
Contributor

merged 1a26a74

@bakineugene
Copy link

Hi, is there a reason why this problem have not been fixed for "withCallback" version?

@dead-horse
Copy link
Member

fixed in acdcd59

@bakineugene
Copy link

thank you

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.

4 participants