rock-req
rock-req copied to clipboard
Async support?
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
?
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.
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.