srmagura / real-cancellable-promise

Cancellable promise library for JavaScript and TypeScript.
https://srmagura.github.io/real-cancellable-promise
MIT License
34 stars 2 forks source link

How does this compare to https://github.com/alkemics/CancelablePromise #1

Closed CMCDragonkai closed 2 years ago

CMCDragonkai commented 2 years ago

I noticed your prior art didn't list this package: https://github.com/alkemics/CancelablePromise

srmagura commented 2 years ago

Good question! real-cancellable-promise and cancelable-promise can do the same things, but the two libraries have different underlying philosophies and behaviors.

The big idea behind real-cancellable-promise is that promise.cancel() should truly cancel the API call, animation, or whatever other operation the promise represents.

real-cancellable-promise

cancelable-promise

CMCDragonkai commented 2 years ago

Oh that's great. I am actually looking to really cancel the underlying async operation.

For alot of web requests this can be done with abort controller.

What are your thoughts regarding other kinds of async operations like file writing... Etc?

srmagura commented 2 years ago

real-cancellable-promise should work well with AbortController.

I am not really a Node.js guy, so I don't know much about file I/O in JavaScript. But real-cancellable-promise should work fine here as long as you can create a cancel function that aborts the file writing operation.

CMCDragonkai commented 2 years ago

Great turns out that even FS has AbortController.