Comments (7)
I think you got it the other way around. Promises always return a single value (could be an Array of values, of course. see Promise.all()). Callbacks indeed could take more than just (err, value)
.
from es6-promisify.
I think you got it the other way around.
Was my proposed example incorrect? It was just a sample, the docs could contain any example.
Promises always return a single value
I know but to me it was not totally obvious how es6-promisify
would wrap a node-style function that executes a callback with multiple args. If you think it's obvious then feel free to close the bug. It should be easy to document how a callback with multiple args gets wrapped by es6-promisify
though, it's only a couple more lines in your docs. You could copy/paste what I added here.
from es6-promisify.
I fully agree! 👍 I'd like that documentation and actually I don't even know what es6-promisify does in this case, do you?
I have misread the description of your second snippet: "For those unfamiliar with promises, THEY would expect it to look more like:". Sorry 😄
from es6-promisify.
I don't even know what es6-promisify does in this case, do you?
Yes. My first example is correct, I tried it. You have to use it like this:
import tmp from 'tmp'; // node builtin
let createTmpDir = promisify(tmp.dir);
createTmpDir()
.then((result) => {
let [tmpPath, removeTmpDir] = result;
// ...
});
from es6-promisify.
Pull requests cheerfully accepted :)
from es6-promisify.
Pull requests cheerfully accepted :)
Feel free to close the issue, it was just a suggestion. I don't have time for a patch right now. Maybe later.
from es6-promisify.
This issue can be closed now. I just saw the new multiArg
feature and it seems well documented: https://github.com/digitaldesignlabs/es6-promisify#handle-callback-multiple-arguments
FWIW, I don't fully understand this change. Any reason why multiArg: true
isn't the default behavior? I can't think of a situation where one would expect it to work like multiArg: false
. It seems convenient as a shortcut but it is confusing if you need to reach multiple callback arguments. Anyway, I updated my use of promisify()
with {multiArg: true}
and it's working fine.
from es6-promisify.
Related Issues (20)
- Promises with multiple arguments group args into an array HOT 3
- Remove "own resolver" functionality HOT 1
- Should detect attempts to promisify promises
- Is it possible to profimify a function in the format of func(arg1, arg2 .. argN, {callback: Function}) HOT 2
- Minify bundle. HOT 2
- Allow promisifying methods (not just functions) HOT 10
- Bundling a promise polyfill is not optimal HOT 1
- Add `thisArg` option usage in readme documentation HOT 1
- Does not work on iOS9 safari HOT 1
- `multiArgs` doesn't work in case of rejection HOT 4
- Invalid assignment error.
- Please add LICENSE file HOT 1
- This library should not require es6-promise,may be I require another promise library. HOT 1
- is it possible to trigger HTTP requests from this plugin? HOT 1
- Latest version only returns first callback value if argumentNames is not set HOT 2
- Deploy on Azure failed
- Unable to promisify localStorage HOT 1
- Does this work with async and await? HOT 2
- Cannot read property 'apply' of undefined HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from es6-promisify.