@operato/utils
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -6,2 +6,11 @@ # Change Log | ||
### [1.2.4](https://github.com/hatiolab/operato/compare/v1.2.3...v1.2.4) (2023-03-13) | ||
### :bug: Bug Fix | ||
* add a constructor parameter that allows async-lock to be auto-locked at creation time ([0d59b0d](https://github.com/hatiolab/operato/commit/0d59b0d0a5c664c32f7dcde3d3e184b117bb2d83)) | ||
### [1.2.3](https://github.com/hatiolab/operato/compare/v1.2.2...v1.2.3) (2023-03-12) | ||
@@ -8,0 +17,0 @@ |
export declare class AsyncLock { | ||
unlock?: any; | ||
promise?: Promise<unknown>; | ||
promise?: Promise<unknown> | undefined; | ||
constructor(lock?: boolean); | ||
lock(): void; | ||
} |
export class AsyncLock { | ||
constructor(lock = false) { | ||
this.promise = new Promise(resolve => (this.unlock = resolve)); | ||
if (lock) { | ||
this.lock(); | ||
} | ||
} | ||
lock() { | ||
@@ -3,0 +9,0 @@ this.promise = new Promise(resolve => (this.unlock = resolve)); |
@@ -5,3 +5,3 @@ { | ||
"author": "heartyoh", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"main": "dist/src/index.js", | ||
@@ -120,3 +120,3 @@ "module": "dist/src/index.js", | ||
}, | ||
"gitHead": "ebabfb6ce5eafc1e1ef524035fab49db445e1a6b" | ||
"gitHead": "20308b22b09e810c2014faacb073e666ddd33a5a" | ||
} |
export class AsyncLock { | ||
unlock?: any | ||
promise?: Promise<unknown> | ||
promise? = new Promise(resolve => (this.unlock = resolve)) | ||
constructor(lock: boolean = false) { | ||
if (lock) { | ||
this.lock() | ||
} | ||
} | ||
lock() { | ||
@@ -6,0 +12,0 @@ this.promise = new Promise(resolve => (this.unlock = resolve)) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
200428
2084