Sha256: b199581471074102ec7b2c89dbbff48249b3c9c9f9261d9fe32a110d76f7a526

Contents?: true

Size: 649 Bytes

Versions: 50

Compression:

Stored size: 649 Bytes

Contents

import {
	Agent,
	ClientRequest,
	RequestOptions,
	AgentCallbackCallback,
	AgentCallbackPromise,
	AgentCallbackReturn
} from './index';

type LegacyCallback = (
	req: ClientRequest,
	opts: RequestOptions,
	fn: AgentCallbackCallback
) => void;

export default function promisify(fn: LegacyCallback): AgentCallbackPromise {
	return function(this: Agent, req: ClientRequest, opts: RequestOptions) {
		return new Promise((resolve, reject) => {
			fn.call(
				this,
				req,
				opts,
				(err: Error | null | undefined, rtn?: AgentCallbackReturn) => {
					if (err) {
						reject(err);
					} else {
						resolve(rtn);
					}
				}
			);
		});
	};
}

Version data entries

50 entries across 50 versions & 3 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.50 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.49 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.48 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.47 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.46 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.45 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.44 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.43 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.42 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.41 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.40 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.39 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.38 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.32 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.31 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.30 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.29 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.28 node_modules/agent-base/src/promisify.ts
immosquare-cleaner-0.1.27 node_modules/agent-base/src/promisify.ts