mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-14 17:21:01 +08:00
[async-lock] update types and tests
This commit is contained in:
7
types/async-lock/async-lock-tests.ts
Normal file → Executable file
7
types/async-lock/async-lock-tests.ts
Normal file → Executable file
@@ -6,9 +6,9 @@ lock.acquire("key", (done) => {
|
||||
done();
|
||||
}, (err, ret) => { /* ... */ });
|
||||
|
||||
lock.acquire("key", (done) => {
|
||||
done();
|
||||
}).then(() => { /* ... */ });
|
||||
lock.acquire("key", (done) => { done(); })
|
||||
.then(() => { /* ... */ })
|
||||
.catch(() => { /* ... */ });
|
||||
|
||||
lock.acquire("key", () => "stringValue")
|
||||
// Check returned value's type is inherited properly
|
||||
@@ -23,6 +23,7 @@ lock.acquire([ "key1", "key2" ], (done) => {
|
||||
}, (err, ret) => { /* ... */ });
|
||||
|
||||
lock.isBusy();
|
||||
lock.isBusy('key')
|
||||
|
||||
const lock2 = new AsyncLock({ timeout : 5000 });
|
||||
const lock3 = new AsyncLock({ maxPending : 5000 });
|
||||
|
||||
4
types/async-lock/index.d.ts
vendored
Normal file → Executable file
4
types/async-lock/index.d.ts
vendored
Normal file → Executable file
@@ -21,13 +21,13 @@ declare class AsyncLock {
|
||||
|
||||
acquire<T>(key: string | string[],
|
||||
fn: (() => T | PromiseLike<T>) | ((done: AsyncLockDoneCallback<T>) => any),
|
||||
opts?: AsyncLockOptions): PromiseLike<T>;
|
||||
opts?: AsyncLockOptions): Promise<T>;
|
||||
acquire<T>(key: string | string[],
|
||||
fn: (done: AsyncLockDoneCallback<T>) => any,
|
||||
cb: AsyncLockDoneCallback<T>,
|
||||
opts?: AsyncLockOptions): void;
|
||||
|
||||
isBusy(): boolean;
|
||||
isBusy(key?: string): boolean;
|
||||
}
|
||||
|
||||
declare namespace AsyncLock { }
|
||||
|
||||
0
types/async-lock/tsconfig.json
Normal file → Executable file
0
types/async-lock/tsconfig.json
Normal file → Executable file
0
types/async-lock/tslint.json
Normal file → Executable file
0
types/async-lock/tslint.json
Normal file → Executable file
Reference in New Issue
Block a user