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

Question #24

Closed
rmrewak opened this issue Apr 6, 2016 · 1 comment
Closed

Question #24

rmrewak opened this issue Apr 6, 2016 · 1 comment

Comments

@rmrewak
Copy link

rmrewak commented Apr 6, 2016

@bevacqua Thanks for the amazing work done.

Use Function() as a "no-op".

function (cb) {
  setTimeout(cb || Function(), 2000);
}

why not use if-else and do not call setTimeout at all ?

@bevacqua
Copy link
Owner

bevacqua commented Apr 6, 2016

Say you have an external API method with a opts, done? signature. That method internally calls many other functions, some of which are asynchronous as well. If you set done = done || Function() or some such at the entry point, you won't have to check whether a callback is being passed in the internal functions.

@bevacqua bevacqua closed this as completed Apr 6, 2016
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