@matrixai/async-locks
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -10,5 +10,5 @@ import type { ResourceAcquire } from '@matrixai/resources'; | ||
waitForUnlock(timeout?: number): Promise<void>; | ||
withF<T>(f: (resources: [Lock]) => Promise<T>, timeout?: number): Promise<T>; | ||
withG<T, TReturn, TNext>(g: (resources: [Lock]) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withF<T>(f: (lock: Lock) => Promise<T>, timeout?: number): Promise<T>; | ||
withG<T, TReturn, TNext>(g: (lock: Lock) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
} | ||
export default Lock; |
@@ -62,6 +62,6 @@ "use strict"; | ||
async withF(f, timeout) { | ||
return (0, resources_1.withF)([this.lock(timeout)], f); | ||
return (0, resources_1.withF)([this.lock(timeout)], ([lock]) => f(lock)); | ||
} | ||
withG(g, timeout) { | ||
return (0, resources_1.withG)([this.lock(timeout)], g); | ||
return (0, resources_1.withG)([this.lock(timeout)], ([lock]) => g(lock)); | ||
} | ||
@@ -68,0 +68,0 @@ } |
@@ -18,7 +18,7 @@ import type { MutexInterface } from 'async-mutex'; | ||
waitForUnlock(timeout?: number): Promise<void>; | ||
withReadF<T>(f: (resources: [RWLockReader]) => Promise<T>, timeout?: number): Promise<T>; | ||
withWriteF<T>(f: (resources: [RWLockReader]) => Promise<T>, timeout?: number): Promise<T>; | ||
withReadG<T, TReturn, TNext>(g: (resources: [RWLockReader]) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withWriteG<T, TReturn, TNext>(g: (resources: [RWLockReader]) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withReadF<T>(f: (lock: RWLockReader) => Promise<T>, timeout?: number): Promise<T>; | ||
withWriteF<T>(f: (lock: RWLockReader) => Promise<T>, timeout?: number): Promise<T>; | ||
withReadG<T, TReturn, TNext>(g: (lock: RWLockReader) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withWriteG<T, TReturn, TNext>(g: (lock: RWLockReader) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
} | ||
export default RWLockReader; |
@@ -104,12 +104,12 @@ "use strict"; | ||
async withReadF(f, timeout) { | ||
return (0, resources_1.withF)([this.read(timeout)], f); | ||
return (0, resources_1.withF)([this.read(timeout)], ([lock]) => f(lock)); | ||
} | ||
async withWriteF(f, timeout) { | ||
return (0, resources_1.withF)([this.write(timeout)], f); | ||
return (0, resources_1.withF)([this.write(timeout)], ([lock]) => f(lock)); | ||
} | ||
withReadG(g, timeout) { | ||
return (0, resources_1.withG)([this.read(timeout)], g); | ||
return (0, resources_1.withG)([this.read(timeout)], ([lock]) => g(lock)); | ||
} | ||
withWriteG(g, timeout) { | ||
return (0, resources_1.withG)([this.write(timeout)], g); | ||
return (0, resources_1.withG)([this.write(timeout)], ([lock]) => g(lock)); | ||
} | ||
@@ -116,0 +116,0 @@ } |
@@ -20,7 +20,7 @@ import type { MutexInterface } from 'async-mutex'; | ||
waitForUnlock(timeout?: number): Promise<void>; | ||
withReadF<T>(f: (resources: [RWLockWriter]) => Promise<T>, timeout?: number): Promise<T>; | ||
withWriteF<T>(f: (resources: [RWLockWriter]) => Promise<T>, timeout?: number): Promise<T>; | ||
withReadG<T, TReturn, TNext>(g: (resources: [RWLockWriter]) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withWriteG<T, TReturn, TNext>(g: (resources: [RWLockWriter]) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withReadF<T>(f: (lock: RWLockWriter) => Promise<T>, timeout?: number): Promise<T>; | ||
withWriteF<T>(f: (lock: RWLockWriter) => Promise<T>, timeout?: number): Promise<T>; | ||
withReadG<T, TReturn, TNext>(g: (lock: RWLockWriter) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
withWriteG<T, TReturn, TNext>(g: (lock: RWLockWriter) => AsyncGenerator<T, TReturn, TNext>, timeout?: number): AsyncGenerator<T, TReturn, TNext>; | ||
} | ||
export default RWLockWriter; |
@@ -152,12 +152,12 @@ "use strict"; | ||
async withReadF(f, timeout) { | ||
return (0, resources_1.withF)([this.read(timeout)], f); | ||
return (0, resources_1.withF)([this.read(timeout)], ([lock]) => f(lock)); | ||
} | ||
async withWriteF(f, timeout) { | ||
return (0, resources_1.withF)([this.write(timeout)], f); | ||
return (0, resources_1.withF)([this.write(timeout)], ([lock]) => f(lock)); | ||
} | ||
withReadG(g, timeout) { | ||
return (0, resources_1.withG)([this.read(timeout)], g); | ||
return (0, resources_1.withG)([this.read(timeout)], ([lock]) => g(lock)); | ||
} | ||
withWriteG(g, timeout) { | ||
return (0, resources_1.withG)([this.write(timeout)], g); | ||
return (0, resources_1.withG)([this.write(timeout)], ([lock]) => g(lock)); | ||
} | ||
@@ -164,0 +164,0 @@ } |
{ | ||
"name": "@matrixai/async-locks", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"author": "Roger Qiu", | ||
@@ -5,0 +5,0 @@ "description": "Asynchronous locking utilities", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42722