itz-locking-time
Use promise-based non-ipc locks
API
.runOnce(id, fnc, t)
: Run a function once or await it's current execution
- id unique identifier
- fnc() function that is going to be executed once or if it's already executing is being awaited
- t: Throw or stay silent
.runNext(id, fnc, t)
: Run function or if already running run it again afterwards. Will automatically batch all next calls per iteration
- id unique identifier
- fnc() function that is going to be executed once or if it's already executing is being awaited
- t: Throw or stay silent
Usage
const Lock = const lock = const wait = const someFnc = async { await } lock // will runawait lock // will await first execution lock // will runlock // will queue next executionawait lock // will await next execution