medikoo / deferred

Modular and fast Promises implementation for JavaScript
ISC License
364 stars 20 forks source link

Reconsider promisify treatment of multiple arguments #34

Open medikoo opened 10 years ago

medikoo commented 10 years ago

Problem well discussed here: https://github.com/petkaantonov/bluebird/issues/307

In short: non-breaking change to external API may result in breaking change for module that relies on promisify, that certainly raises the issue.

medikoo commented 8 years ago

Proposal:

nejucomo commented 8 years ago

I'm new to node, but familiar with Twisted's deferred (from python), and after a quick skim of this README this looks like the library I want. However, the very first node call I tried to promisify was child_process.execFile which is a multi-arg callback api: callback(error, stdout, stderr). I just wanted to point this out so that once a solution is implemented, the docs could use execFile as an example.

FWIW, I prefer the {multipleResult: true} API design, and dislike any kind of automatic coercion logic like:

if (arguments.length > 1) {
  /* use an array */
} else {
  /* use arguments[0] */
}

-because this introduces a type ambiguity: It prevents writing a generic callback that tries to distinguish these two cases, because arguments[0] may itself be an Array.

medikoo commented 8 years ago

@nejucomo thanks for comment, this one definitely will be addressed and will be published with v1