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

Async support? #5

Open
cb-rnag opened this issue Dec 22, 2023 · 2 comments
Open

Async support? #5

cb-rnag opened this issue Dec 22, 2023 · 2 comments

Comments

@cb-rnag
Copy link

cb-rnag commented Dec 22, 2023

Is there any future plans for async support, e.g. with await?

I like libraries like node-fetch and axios, as one of the things they ship "out of the box" is ability to use promise and support async-await pattern in node/express.

My question, has the benchmarks for this library - which are pretty impressive btw - been tested in an async environment? Also, how would one go about "promisifying" a library such as rock-req, if I may ask? That is, would it be possible to wrap such a library in an async block to use with await?

@dgrelaud
Copy link
Member

dgrelaud commented Jan 8, 2024

Hello,

Yes, we could support await/async.

Have you tried to use the native NodeJS function to promisify rock.req with util.promisify?

const rockGet = util.promisify(rock.get);

has the benchmarks for this library - which are pretty impressive btw - been tested in an async environment?

Not yet. In general, it is slower.

@cb-rnag
Copy link
Author

cb-rnag commented Jan 19, 2024

Nice, I haven't played around with (or even heard of) util.promisify but that looks promising to me (no pun intended).

Will try with that approach and see if I can get it to work. However, still do agree that it would be great if rock-req support this OOTB, as I feel it could be a worthwhile addition. I would be happy to implement as well, but I'm not sure on the process for going about that, e.g. how can await/async be added natively.

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