Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Support Promise API #33

Open
dominic-p opened this issue May 27, 2019 · 3 comments
Open

Support Promise API #33

dominic-p opened this issue May 27, 2019 · 3 comments

Comments

@dominic-p
Copy link

dominic-p commented May 27, 2019

With Promises being available in Node for a while now, it would be great if this library could return Promises.

Side note: has anyone tried this with util.promsify? Does that work as expected?

@dominic-p dominic-p changed the title s Support Promise API May 27, 2019
@aikar
Copy link

aikar commented Nov 2, 2019

const util = require("util");
const lfLock = util.promisify(lf.lock);
const lfUnlock = util.promisify(lf.unlock);
await lfLock('a', {retries: 60000, retryWait: 100});
await lfUnlock('a');

works fine.

@dominic-p
Copy link
Author

Thanks for the confirmation. I have been using it with promisify as well. It would still be nice if Promises were supported natively in my opinion, but it's a huge deal since promisify works.

@aikar
Copy link

aikar commented Nov 4, 2019

Considering the async API's do not have any special return value at this time, I believe it would be safe to add promise support as a non breaking change.

If callback is null, return a promise, else behave the way it currently does.
Could potentially always return a promise even.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants