bin/response.js
function (data, circuitbreakerState, callback) {

        const responder = (circuitbreakerState===CB.OPEN) ? config.bypass : config.handler;

        // call the handler using its expected paradigm
        const promise = responder.length > 1
            ? new Promise(function(resolve, reject) {
                responder(data, function(err, result) {
                    if (err) return reject(err);
                    resolve(result);
                });
            })
            : Promise.resolve(responder(data));

        // provide an asynchronous response in the expected paradigm
        if (typeof callback !== 'function') return promise;
        promise.then(
            function (data) { callback(null, data); },
            function (err) { callback(err, null); }
        );
    }
function (data, circuitbreakerState, callback) {

        const responder = (circuitbreakerState===CB.OPEN) ? config.bypass : config.handler;

        // call the handler using its expected paradigm
        const promise = responder.length > 1
            ? new Promise(function(resolve, reject) {
                responder(data, function(err, result) {
                    if (err) return reject(err);
                    resolve(result);
                });
            })
            : Promise.resolve(responder(data));

        // provide an asynchronous response in the expected paradigm
        if (typeof callback !== 'function') return promise;
        promise.then(
            function (data) { callback(null, data); },
            function (err) { callback(err, null); }
        );
    }
function ( data , circuitbreakerState , callback ) { const responder = ( circuitbreakerState === CB . OPEN ) ? config . bypass : config . handler ; // call the handler using its expected paradigm const promise = responder . length > 1 ? new Promise ( function ( resolve , reject ) { responder ( data , function ( err , result ) { if ( err ) return reject ( err ) ; resolve ( result ) ; } ) ; } ) : Promise . resolve ( responder ( data ) ) ; // provide an asynchronous response in the expected paradigm if ( typeof callback !== 'function' ) return promise ; promise . then ( function ( data ) { callback ( null , data ) ; } , function ( err ) { callback ( err , null ) ; } ) ; }
define the response function wrapper
define the response function wrapper