@jagi/mutex
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@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();
});

Dependencies (0)

    Dev Dependencies (4)

    Package Sidebar

    Install

    npm i @jagi/mutex

    Weekly Downloads

    11

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    8.39 kB

    Total Files

    11

    Last publish

    Collaborators

    • lukejagodzinski