0.2.1 • Published 5 years ago

@determapp/lock v0.2.1

Weekly downloads
-
License
GPL-3.0
Repository
gitlab
Last release
5 years ago

DetermApp Lock

A very simple lock implementation which is used at DetermApp.

import { Lock } from '@determapp/lock';

async function main() {
  const myLock = new Lock();

  await myLock.lockAsync(); // waits until all previous locks were followed by an unlock
  console.log(myLock.getIsLocked());  // true
  myLock.unlock();

  console.log(myLock.getIsLocked());  // false

  myLock.lockNow(); // synchronous
  myLock.lockNow(); // throws if the lock is already acquired (like now)
}

main();

Commands

npm run build

  • builds this component
  • executed as prepare hook
0.2.1

5 years ago

0.2.0

6 years ago