index.js
function () {
    var firstObject = beatmap.hitObjects[0];
    var lastObject  = beatmap.hitObjects[beatmap.hitObjects.length - 1];

    var totalBreakTime = 0;

    beatmap.breakTimes.forEach(function (breakTime) {
      totalBreakTime += (breakTime.endTime - breakTime.startTime);
    });

    if (firstObject && lastObject) {
      beatmap.totalTime    = Math.floor(lastObject.startTime / 1000);
      beatmap.drainingTime = Math.floor((lastObject.startTime - firstObject.startTime - totalBreakTime) / 1000);
    } else {
      beatmap.totalTime    = 0;
      beatmap.drainingTime = 0;
    }
  }
function () {
    var firstObject = beatmap.hitObjects[0];
    var lastObject  = beatmap.hitObjects[beatmap.hitObjects.length - 1];

    var totalBreakTime = 0;

    beatmap.breakTimes.forEach(function (breakTime) {
      totalBreakTime += (breakTime.endTime - breakTime.startTime);
    });

    if (firstObject && lastObject) {
      beatmap.totalTime    = Math.floor(lastObject.startTime / 1000);
      beatmap.drainingTime = Math.floor((lastObject.startTime - firstObject.startTime - totalBreakTime) / 1000);
    } else {
      beatmap.totalTime    = 0;
      beatmap.drainingTime = 0;
    }
  }
function ( ) { var firstObject = beatmap . hitObjects [ 0 ] ; var lastObject = beatmap . hitObjects [ beatmap . hitObjects . length - 1 ] ; var totalBreakTime = 0 ; beatmap . breakTimes . forEach ( function ( breakTime ) { totalBreakTime += ( breakTime . endTime - breakTime . startTime ) ; } ) ; if ( firstObject && lastObject ) { beatmap . totalTime = Math . floor ( lastObject . startTime / 1000 ) ; beatmap . drainingTime = Math . floor ( ( lastObject . startTime - firstObject . startTime - totalBreakTime ) / 1000 ) ; } else { beatmap . totalTime = 0 ; beatmap . drainingTime = 0 ; } }
Compute the total time and the draining time of the beatmap
Compute the total time and the draining time of the beatmap