Skip to content
/ myturn Public

Super simple library to make sure Promises wait their turn to resolve.

License

Notifications You must be signed in to change notification settings

hieyou1/myturn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e1d6275 · Dec 1, 2024

History

3 Commits
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024
Dec 1, 2024

Repository files navigation

myturn

Super simple library to make sure Promises wait their turn to resolve. It's probably not best practice to use this library in production because it could negate the performance benefits of asynchronous code.

Usage

import { MyTurn } from "myturn";

let lock = new MyTurn();

console.log(lock.isLocked); // false

await lock.wait();

try {
  // Something that really shouldn't be happening at the same time as another thing
  console.log(lock.isLocked); // true
} finally {
  lock.done();
}

console.log(lock.isLocked); // false
// Ready to be locked again!

License

MIT

About

Super simple library to make sure Promises wait their turn to resolve.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published