r97873 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97872‎ | r97873 | r97874 >
Date:00:27, 23 September 2011
Author:tparscal
Status:deferred
Tags:
Comment:
Added getCoverage method
Modified paths:
  • /trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/synth/bases/es.AggregateArray.js
@@ -51,6 +51,22 @@
5252 return Math.max( 0, sum + this.length - 1 );
5353 };
5454
 55+es.AggregateArray.prototype.getCoverage = function( start, end ) {
 56+ var result = { 'on': [], 'off': [] },
 57+ sum = 0,
 58+ len;
 59+ for ( var i = 0, length = this.length; i < length; i++ ) {
 60+ len = this[i].getLength();
 61+ if ( sum >= start && sum + len < end ) {
 62+ result.on.push( this[i] );
 63+ } else {
 64+ result.off.push( this[i] );
 65+ }
 66+ sum += len
 67+ }
 68+ return result;
 69+};
 70+
5571 es.AggregateArray.prototype.select = function( start, end ) {
5672 // Support es.Range object as first argument
5773 if ( typeof start.from === 'number' && typeof start.to === 'number') {

Status & tagging log