DefinitelyTyped/types/async-lock/index.d.ts
Alejandro Fernández Haro 7968b99ad1 async-lock: Generics in returned values (#23131)
* 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
2018-01-29 12:26:24 -08:00

36 lines
1016 B
TypeScript

// Type definitions for async-lock
// Project: https://github.com/rain1017/async-lock
// Definitions by: Elisée MAURER <https://github.com/elisee>, Alejandro <https://github.com/afharo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
interface AsyncLockDoneCallback<T> {
(err?: Error, ret?: T): void;
}
interface AsyncLockOptions {
timeout?: number;
maxPending?: number;
domainReentrant?: boolean;
Promise?: any;
}
declare class AsyncLock {
constructor(options?: AsyncLockOptions);
acquire<T>(key: string | string[],
fn: (() => T | PromiseLike<T>) | ((done: AsyncLockDoneCallback<T>) => any),
opts?: AsyncLockOptions): PromiseLike<T>;
acquire<T>(key: string | string[],
fn: (done: AsyncLockDoneCallback<T>) => any,
cb: AsyncLockDoneCallback<T>,
opts?: AsyncLockOptions): void;
isBusy(): boolean;
}
declare namespace AsyncLock { }
export = AsyncLock;