index.js
function callPromise(fn, args) {
	return new Promise((resolve, reject) => {
		// promisified callback
		function callback(err,other) {
			// check if the 'err' is boolean, if so then this is a 'exists' callback special case
			if (err && (typeof err !== 'boolean')) return reject(err);
			// convert arguments to proper array, ignoring error argument
			let args = Array.prototype.slice.call(arguments, 1);
			// if arguments length is one or more resolve arguments as array,
			// otherwise resolve the argument as is.
			return resolve(args.length < 2 ? args[0] : args);
		}
		fn.apply(null, args.concat([callback]));
	});
}
function callPromise(fn, args) {
	return new Promise((resolve, reject) => {
		// promisified callback
		function callback(err,other) {
			// check if the 'err' is boolean, if so then this is a 'exists' callback special case
			if (err && (typeof err !== 'boolean')) return reject(err);
			// convert arguments to proper array, ignoring error argument
			let args = Array.prototype.slice.call(arguments, 1);
			// if arguments length is one or more resolve arguments as array,
			// otherwise resolve the argument as is.
			return resolve(args.length < 2 ? args[0] : args);
		}
		fn.apply(null, args.concat([callback]));
	});
}
function callPromise ( fn , args ) { return new Promise ( ( resolve , reject ) => { // promisified callback function callback ( err , other ) { // check if the 'err' is boolean, if so then this is a 'exists' callback special case if ( err && ( typeof err !== 'boolean' ) ) return reject ( err ) ; // convert arguments to proper array, ignoring error argument let args = Array . prototype . slice . call ( arguments , 1 ) ; // if arguments length is one or more resolve arguments as array, // otherwise resolve the argument as is. return resolve ( args . length < 2 ? args [ 0 ] : args ) ; } fn . apply ( null , args . concat ( [ callback ] ) ) ; } ) ; }
Call method with promises
Call method with promises