3 ms·
Yup. Wrapping synchronous code in a callback does not magically make all that wrapped code async. Instead it just makes it a really really large blocking functi
by malandrew 13y ago
Yup. Wrapping synchronous code in a callback does not magically make all that wrapped code async. Instead it just makes it a really really large blocking function. I've seen this before in other libraries and tools in the node.js ecosystem when I want to use something on the server instead of at the command line. I've ended up having to completely rewrite some libs/tools to make them full async for server use because their use of synchronous code internally was everywhere in the code base.
I'd love it if there was a quick way to analyze a code base to tell you what level of asychronicity you've achieved. I don't know how such a tool would be written, but I reckon you'd need to start with a list of node.js core API functions sorted into those that are sync and those that are async. Then the level of sync to async is roughly a function of average function size and the ratio of sync to async functions. Many small async functions that consume async core functions would be ideal.
That being said, still kudos to the author of this lib and other others for contributing code to the commons.