lib/parallel.js
function createWrapper(fn, ctx) {
  return function() {
    return new Promise(function(resolve, reject) {
      var start = Date.now();

      var cb = function(err) {
        if (err) return reject(err);
        resolve(Date.now() - start);
      };

      // Wrap generator functions
      if (fn && fn.constructor.name === 'GeneratorFunction') {
        fn = Promise.coroutine(fn);
      }

      var res = fn.call(ctx || this, cb);

      // Synchronous spec, or using promises rather than callbacks
      if (!fn.length || (res && res.then)) {
        Promise.resolve(res).then(function() {
          resolve(Date.now() - start);
        }, reject);
      }
    });
  };
}
function createWrapper(fn, ctx) {
  return function() {
    return new Promise(function(resolve, reject) {
      var start = Date.now();

      var cb = function(err) {
        if (err) return reject(err);
        resolve(Date.now() - start);
      };

      // Wrap generator functions
      if (fn && fn.constructor.name === 'GeneratorFunction') {
        fn = Promise.coroutine(fn);
      }

      var res = fn.call(ctx || this, cb);

      // Synchronous spec, or using promises rather than callbacks
      if (!fn.length || (res && res.then)) {
        Promise.resolve(res).then(function() {
          resolve(Date.now() - start);
        }, reject);
      }
    });
  };
}
function createWrapper ( fn , ctx ) { return function ( ) { return new Promise ( function ( resolve , reject ) { var start = Date . now ( ) ; var cb = function ( err ) { if ( err ) return reject ( err ) ; resolve ( Date . now ( ) - start ) ; } ; // Wrap generator functions if ( fn && fn . constructor . name === 'GeneratorFunction' ) { fn = Promise . coroutine ( fn ) ; } var res = fn . call ( ctx || this , cb ) ; // Synchronous spec, or using promises rather than callbacks if ( ! fn . length || ( res && res . then ) ) { Promise . resolve ( res ) . then ( function ( ) { resolve ( Date . now ( ) - start ) ; } , reject ) ; } } ) ; } ; }
Returns a wrapper for a given runnable's fn, including specs or hooks.
Optionally binds the function handler to the passed context. Resolves
with the duration of the fn.

@param   {function} fn
@param   {function} [ctx]
@returns {function}
Returns a wrapper for a given runnable s fn including specs or hooks . Optionally binds the function handler to the passed context . Resolves with the duration of the fn .