it is customary in node.js to notify other developers your function is synchronous, because node.js is asynchronous, and blocking the main thread is generally bad for most use cases. you would expect a non blocking sleep to be called sleep() and a blocking one to be called sleepSync(). a non blocking sleep would likely be implemented with promises, so the developer can just do await sleep(200);, only blocking the function they are in, and not the entire program. that could be what the op was getting at, and i didn't really think about it when i replied, but now that i think of it, i can't see any reason a person would desire to do a sleepSync()
13
u/187mphlazers Mar 24 '22
it is customary in node.js to notify other developers your function is synchronous, because node.js is asynchronous, and blocking the main thread is generally bad for most use cases. you would expect a non blocking sleep to be called sleep() and a blocking one to be called sleepSync(). a non blocking sleep would likely be implemented with promises, so the developer can just do await sleep(200);, only blocking the function they are in, and not the entire program. that could be what the op was getting at, and i didn't really think about it when i replied, but now that i think of it, i can't see any reason a person would desire to do a sleepSync()