Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mtripg6666tdr/async-lock
Promise based simple mutex for JS: preventing from running same code block at the same time.
https://github.com/mtripg6666tdr/async-lock
async async-lock browser javascript lock mutex nodejs promise promise-lock
Last synced: 10 days ago
JSON representation
Promise based simple mutex for JS: preventing from running same code block at the same time.
- Host: GitHub
- URL: https://github.com/mtripg6666tdr/async-lock
- Owner: mtripg6666tdr
- License: mit
- Created: 2022-05-14T10:26:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-08T06:23:58.000Z (over 1 year ago)
- Last Synced: 2024-10-31T17:32:02.575Z (15 days ago)
- Topics: async, async-lock, browser, javascript, lock, mutex, nodejs, promise, promise-lock
- Language: TypeScript
- Homepage: https://npmjs.com/package/@mtripg6666tdr/async-lock
- Size: 11.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# async-lock
Promise based simple mutex for JS: preventing from running same code block at the same time.## API
- LockObj (class)
used to store mutex statuses.
- lock (function)
used to lock statement, just like C# `lock{}`.# Usage
```js
const { lock, LockObj } = require("@mtripg6666tdr/async-lock");const locker = new LockObj();
const someFunction = async () => {
return await lock(locker, () => {
// do some stuff.
});
};
```## Example
Please see [test file](test/index.js).## License
[MIT](LICENSE)