-
Notifications
You must be signed in to change notification settings - Fork 165
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
Promise grammar support. #166
Comments
Hi @Vallista I looked into promises, but since this is an event based model vs a callback based one, it isn't clear how to make use of promises in the API. Can you provide an outline (either in text or as a PR) for how promises could be incorporated in the API? |
const form = new multiparty.Form()
const [fields, files] = await form.parse(ctx.req) |
Would like to have a async iterator... kinda best of both worlds awaitable + event based (can yield one entry at the time) const form = new multiparty.Form()
for await (let entry of form.parse(req)) {
console.log(entry.headers) // [ [key, value], ... ]
console.log(entry.name) // field name
console.log(entry.fileName) // filename
// entry.value is an async iterator also
for await (let chunk of entry.value) {
// do something with chunk
}
// or
stream.Readable.from(entry.value).pipe(fs.createWriteStream(entry.filename))
} but it seems farfetched judging by the design of this lib |
Maybe something like this?
...and then call it like this:
|
Hey 👋 I was having a hard time recieving files using Nuxt 3 and its Nitro server with multiparty. Your |
Do we still need to manually promisify this in the end of 2023? |
If someone wants to start a PR to add promises, that would be a big help :) |
I thought that I would add it because it was not promise while using it. What do you think?
The text was updated successfully, but these errors were encountered: