src/promissory-arbiter.js
function subscriptionInvoker (subscription, data, topic) {
    var result;

    if (subscription.fn.length === 3) {
      return new Promise(function promiseResolver (fulfill, reject) {
        subscription.fn.call(
          subscription.context, data, topic, function callback (err, succ) {
            return err ? reject(err) : fulfill(succ);
          }
        );
      });
    }

    try {
      result = subscription.fn.call(subscription.context, data, topic);
    } catch (e) {
      return Promise.reject(e);
    }

    if (result && typeof result.then === 'function') {
      return result;
    }

    return Promise.resolve(result);
  }
function subscriptionInvoker (subscription, data, topic) {
    var result;

    if (subscription.fn.length === 3) {
      return new Promise(function promiseResolver (fulfill, reject) {
        subscription.fn.call(
          subscription.context, data, topic, function callback (err, succ) {
            return err ? reject(err) : fulfill(succ);
          }
        );
      });
    }

    try {
      result = subscription.fn.call(subscription.context, data, topic);
    } catch (e) {
      return Promise.reject(e);
    }

    if (result && typeof result.then === 'function') {
      return result;
    }

    return Promise.resolve(result);
  }
function subscriptionInvoker ( subscription , data , topic ) { var result ; if ( subscription . fn . length === 3 ) { return new Promise ( function promiseResolver ( fulfill , reject ) { subscription . fn . call ( subscription . context , data , topic , function callback ( err , succ ) { return err ? reject ( err ) : fulfill ( succ ) ; } ) ; } ) ; } try { result = subscription . fn . call ( subscription . context , data , topic ) ; } catch ( e ) { return Promise . reject ( e ) ; } if ( result && typeof result . then === 'function' ) { return result ; } return Promise . resolve ( result ) ; }
Invokes a subscription with the required parameters and acts as an adapter for the different asynchronous mechanisms behavior. i.e. node-style callbacks and promises.
Invokes a subscription with the required parameters and acts as an adapter for the different asynchronous mechanisms behavior . i . e . node - style callbacks and promises .