1.0.2 • Published 5 years ago

@jagi/mutex v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

@jagi/mutex

Simple TypeScript mutex implementation

Installation

npm install @jagi/mutex -S

or

yarn add @jagi/mutex

Usage

import Mutex from "@jagi/mutex";

const mutext = new Mutex();

const asyncActionResult = await mutex.run(async () => {
  // Running asynchronous action.
  return await asyncAction();
});

mutex.run(async () => {
  // This action will wait for the first one to finish.
  await anotherAsyncAction();
});