Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support promises in async version

See original GitHub issue

Hey! Great library!

I am using it in the browser, and it would be great if the async versions would support promises as well instead of just callbacks.

Ideally it would look something like this:

const buffer = await
    'index.html': fflate.strToU8(str),
    // other files...
  { level: 4 }

It looks like synchronous code but it doesn’t block the main thread.

It makes sense to support promises, newer versions of node are doing so with stuff like fs/promises and timers/promises

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

101arrowzcommented, Jul 8, 2021

I have thought of using a separate build for IE11. I write ESNext for all of my personal projects and make heavy use of Promise; usually I don’t try to support IE11 as it’s a dead browser, but when I do I use the polyfill you linked for Promise. The problem for a project like this is that the entire package is designed to be lower-level and to support ancient engines, so adding one component of new JS is incongruous. Check out #75, in which fflate needed to support another rare engine, V4: if there’s a special bug with Promise in V4, as there was for typed arrays, I’d have to commit to supporting it. I’ve also been asked to add support for WHATWG streams in the streaming APIs, but those are even more recent and even more unsupported than Promise. Basically, the fewer modern features fflate uses, the more maintainable it is for me and the more compatible it is for every user.

As support for features of new JS is such a popular feature request, I’ll create a wrapper for fflate that supports the modern features you want. See #80 for more info.

101arrowzcommented, Jul 8, 2021

Future users can just search the issues tab for “Promise” and they’ll find it. Thanks for the feature request!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use promises - Learn web development | MDN
Promises are the foundation of asynchronous programming in modern JavaScript. A promise is an object returned by an asynchronous function, ...
Read more >
Understanding the Event Loop, Callbacks, Promises, and ...
A promise represents the completion of an asynchronous function. It is an object that might return a value in the future. It accomplishes...
Read more >
Async functions: making promises friendly -
Async functions allow you to write promise-based code as if it were synchronous.
Read more >
25. Promises for asynchronous programming - Exploring JS
Promises are an alternative to callbacks for delivering the results of an asynchronous computation. They require more effort from implementors of asynchronous ...
Read more >
Promises, async/await - The Modern JavaScript Tutorial
Promises, async/await · Introduction: callbacks · Promise · Promises chaining · Error handling with promises · Promise API · Promisification · Microtasks ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found