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

uniform parameters #7

Open
jayrbolton opened this issue Aug 30, 2017 · 0 comments
Open

uniform parameters #7

jayrbolton opened this issue Aug 30, 2017 · 0 comments

Comments

@jayrbolton
Copy link

jayrbolton commented Aug 30, 2017

This is just a question/idea post:

Sometimes I accidentally do not list the correct parameters in the next task in the waterfall:

waterfall([
  (cb) => fs.ensureDir('/tmp/x', cb),
  (cb) => fs.readFile('/tmp/y', cb)
], callback)

In the above I forgot that fs.ensureDir returns the directory path, so I'll have a bug where cb in the second task is assigned to the wrong thing, and it'll take me a while to catch. For an api with sparse documentation, sometimes I dont really know what arguments the callback will have. This is more tricky when the callback takes several arguments. So I was thinking of making a variation of run-waterfall (run-waterfall-uniform?) that always has tasks with two parameters, where the first parameter is always the array of callback arguments, and the second parameter is always the callback function:

waterfall([
  (cb) => fs.ensureDir('/tmp/x', cb),
  ([dir], cb) => fs.readFile('/tmp/y', cb),
  ([contents], cb) => etc
], callback)

The advantage is just that I know my cb will always get assigned correctly. Whaddya think?

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

1 participant