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
appmap-0.66.2 ./node_modules/agent-base/src/promisify.ts
appmap-0.66.1 ./node_modules/agent-base/src/promisify.ts
appmap-0.66.0 ./node_modules/agent-base/src/promisify.ts
appmap-0.65.1 ./node_modules/agent-base/src/promisify.ts
appmap-0.65.0 ./node_modules/agent-base/src/promisify.ts
isomorfeus-puppetmaster-0.5.2 node_modules/agent-base/src/promisify.ts
isomorfeus-puppetmaster-0.5.1 node_modules/agent-base/src/promisify.ts
isomorfeus-puppetmaster-0.5.0 node_modules/agent-base/src/promisify.ts
appmap-0.64.0 ./node_modules/agent-base/src/promisify.ts
appmap-0.63.0 ./node_modules/agent-base/src/promisify.ts