[async-lock] update types and tests

This commit is contained in:
Anatoly Belonog
2018-02-01 19:05:56 +07:00
parent a436740d5d
commit 0e0af52729
4 changed files with 6 additions and 5 deletions

7
types/async-lock/async-lock-tests.ts Normal file → Executable file
View 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
View 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
View File

0
types/async-lock/tslint.json Normal file → Executable file
View File