mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* async-lock: Generics in returned values * Revert promise with "done" test to prove it still works as before * Add test where fn is a promise
30 lines
758 B
TypeScript
30 lines
758 B
TypeScript
|
|
import * as AsyncLock from "async-lock";
|
|
const lock = new AsyncLock();
|
|
|
|
lock.acquire("key", (done) => {
|
|
done();
|
|
}, (err, ret) => { /* ... */ });
|
|
|
|
lock.acquire("key", (done) => {
|
|
done();
|
|
}).then(() => { /* ... */ });
|
|
|
|
lock.acquire("key", () => "stringValue")
|
|
// Check returned value's type is inherited properly
|
|
.then((str) => str.replace("s", "S"));
|
|
|
|
lock.acquire("key", async () => "stringValue")
|
|
// Check returned value's type is inherited properly
|
|
.then((str) => str.replace("s", "S"));
|
|
|
|
lock.acquire([ "key1", "key2" ], (done) => {
|
|
done();
|
|
}, (err, ret) => { /* ... */ });
|
|
|
|
lock.isBusy();
|
|
|
|
const lock2 = new AsyncLock({ timeout : 5000 });
|
|
const lock3 = new AsyncLock({ maxPending : 5000 });
|
|
const lock4 = new AsyncLock({ Promise: null });
|