npm.io
0.1.2 • Published 7 years ago

tmutex

Licence
MIT
Version
0.1.2
Deps
0
Size
41 kB
Vulns
0
Weekly
0

tmutex

Mutex locks for javascript.

Usage

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
}

Contribution and License Agreement

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.

Creds

  • Christopher Jeffrey

License

  • Copyright (c) 2019, Yuan Tao (MIT License).

Keywords