UNPKG

2.12 kBTypeScriptView Raw
1export interface PromisifyAllOptions extends PromisifyOptions {
2 /**
3 * Array of methods to ignore when promisifying.
4 */
5 exclude?: string[];
6}
7export interface PromisifyOptions {
8 /**
9 * Resolve the promise with single arg instead of an array.
10 */
11 singular?: boolean;
12}
13export interface PromiseMethod extends Function {
14 promisified_?: boolean;
15}
16export interface WithPromise {
17 Promise?: PromiseConstructor;
18}
19export interface CallbackifyAllOptions {
20 /**
21 * Array of methods to ignore when callbackifying.
22 */
23 exclude?: string[];
24}
25export interface CallbackMethod extends Function {
26 callbackified_?: boolean;
27}
28/**
29 * Wraps a callback style function to conditionally return a promise.
30 *
31 * @param {function} originalMethod - The method to promisify.
32 * @param {object=} options - Promise options.
33 * @param {boolean} options.singular - Resolve the promise with single arg instead of an array.
34 * @return {function} wrapped
35 */
36export declare function promisify(originalMethod: PromiseMethod, options?: PromisifyOptions): any;
37/**
38 * Promisifies certain Class methods. This will not promisify private or
39 * streaming methods.
40 *
41 * @param {module:common/service} Class - Service class.
42 * @param {object=} options - Configuration object.
43 */
44export declare function promisifyAll(Class: Function, options?: PromisifyAllOptions): void;
45/**
46 * Wraps a promisy type function to conditionally call a callback function.
47 *
48 * @param {function} originalMethod - The method to callbackify.
49 * @param {object=} options - Callback options.
50 * @param {boolean} options.singular - Pass to the callback a single arg instead of an array.
51 * @return {function} wrapped
52 */
53export declare function callbackify(originalMethod: CallbackMethod): CallbackMethod;
54/**
55 * Callbackifies certain Class methods. This will not callbackify private or
56 * streaming methods.
57 *
58 * @param {module:common/service} Class - Service class.
59 * @param {object=} options - Configuration object.
60 */
61export declare function callbackifyAll(Class: Function, options?: CallbackifyAllOptions): void;