lib/synchronization/slave.js
function getLatency(emitter) {
    var start = Date.now();

    return emitter.request('time')
        .then(function (timestamp) {
          var end = Date.now();
          var latency = (end - start) / 2;
          var time = timestamp + latency;

          // apply the first ever retrieved offset immediately.
          if (isFirst) {
            isFirst = false;
            emitter.emit('change', time);
          }

          return latency;
        })
  }
function getLatency(emitter) {
    var start = Date.now();

    return emitter.request('time')
        .then(function (timestamp) {
          var end = Date.now();
          var latency = (end - start) / 2;
          var time = timestamp + latency;

          // apply the first ever retrieved offset immediately.
          if (isFirst) {
            isFirst = false;
            emitter.emit('change', time);
          }

          return latency;
        })
  }
function getLatency ( emitter ) { var start = Date . now ( ) ; return emitter . request ( 'time' ) . then ( function ( timestamp ) { var end = Date . now ( ) ; var latency = ( end - start ) / 2 ; var time = timestamp + latency ; // apply the first ever retrieved offset immediately. if ( isFirst ) { isFirst = false ; emitter . emit ( 'change' , time ) ; } return latency ; } ) }
Request the time of the master and calculate the latency from the
roundtrip time
@param {{request: function}} emitter
@returns {Promise.<number | null>} returns the latency
@private
Request the time of the master and calculate the latency from the roundtrip time