It's All Writing.

Writing makes you happy.

How to implement exlusive control at node

Premise

Do you have such an experience that a bug was entered by neglecting exclusive control during asynchronous process with Promise at node?
If you want to implement exclusive control, you have to use some library which you'll find out in npm.
Because, Promise does not provide syntax like Mutex or synchronized.

You can use await-semaphore library for the purpose.

Code

gist.github.com

Reference

qiita.com bluebirdjs.com