-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Methods for keeping this #23
Comments
Just use bind directly. await pify(linus.walk.bind(linux))(100, 'miles'); |
That's true, I guess that it would be even nicer if pify supported it out of the box though. Maybe it's outside the scope though... await pify(linus, 'walk')(100, 'miles') |
@LinusU How would it know what to bind to? You would have had to pass the |
@sindresorhus He wants that this example await pify(linus, 'walk')(100, 'miles') binds the |
Yeah, not worth saving just a few characters. Using |
Yes, what @SamVerschueren said, I should have been more clear. I don't know if it's the cleanest approach, my main goal is just to keep the code clean and readable. I guess that we are at a point where many libraries are transitioning into promises, but it will probably be a long time until we are all the way there. The problem I see with doing, e.g. The function bind operator could solve this by using |
With using
Your tests should catch that. |
I've rarely encountered the need to use |
True, I guess that this is good enough for now 👍 thanks for the discussion |
I find that I quite often need to preserve
this
when calling functions that takes callbacks. I have used something similar to the code below, but I would like to hear what you think of the matter.Is there an easy way to support this use case?
The text was updated successfully, but these errors were encountered: