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

Promisify encodeWav.js ? #12

Open
jmarcosfer opened this issue Jan 27, 2022 · 1 comment
Open

Promisify encodeWav.js ? #12

jmarcosfer opened this issue Jan 27, 2022 · 1 comment

Comments

@jmarcosfer
Copy link

jmarcosfer commented Jan 27, 2022

Currently encodeWav expects a callback that will be passed the blob after a 30ms timeout.

Why is the timeout necessary in a function that appears to be otherwise fully synchronous? I tried swapping the setTimeout for a simple return blob; and it works fine.

Assuming there's some asynchronicity that has to be waited for, why not return a promise that resolves with the blob?

In my use case, I'm encoding many different chunks of audio and then putting the blobs into a zip file for download, so I have to wait for all blobs to be returned. The callback was not a practical solution for me, but maybe other people using this library typically don't have this problem and are okay with the callback solution.

I could submit a PR with a very simple change to promisify encodeWav, but I wanted to understand the library's rationale first.

Thanks!

@guest271314
Copy link

I tried swapping the setTimeout for a simple return blob; and it works fine.

I could submit a PR with a very simple change to promisify encodeWav

If return blob works why is using async or Promise necessary?

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