Mutex locks for javascript.
const {Lock} = require('tmutex');
const lock = Lock.create();
async function doSomething() {
const unlock = await lock();
try {
await _doSomething();
} finally {
unlock();
}
}
async function _doSomething() {
// actually do something async
}
If you contribute code to this project, you are implicitly allowing your code to be distributed under the MIT license. You are also implicitly verifying that all code is your original work.
- Christopher Jeffrey
- Copyright (c) 2019, Yuan Tao (MIT License).