apps/notifications/src/panel/indices-to-html/index.js
function find_largest_range( rs ) {
	let r_id = -1,
		r_size = 0,
		i;

	if ( rs.length < 1 ) {
		return null;
	}

	for ( i = 0; i < rs.length; i++ ) {
		if ( null === rs[ i ] ) {
			continue;
		}

		// Set on first valid range and subsequently larger ranges
		if ( -1 === r_id || rs[ i ].indices[ 1 ] - rs[ i ].indices[ 0 ] > r_size ) {
			r_id = i;
			r_size = rs[ i ].indices[ 1 ] - rs[ i ].indices[ 0 ];
		}
	}

	return r_id;
}
function find_largest_range( rs ) {
	let r_id = -1,
		r_size = 0,
		i;

	if ( rs.length < 1 ) {
		return null;
	}

	for ( i = 0; i < rs.length; i++ ) {
		if ( null === rs[ i ] ) {
			continue;
		}

		// Set on first valid range and subsequently larger ranges
		if ( -1 === r_id || rs[ i ].indices[ 1 ] - rs[ i ].indices[ 0 ] > r_size ) {
			r_id = i;
			r_size = rs[ i ].indices[ 1 ] - rs[ i ].indices[ 0 ];
		}
	}

	return r_id;
}
function find_largest_range ( rs ) { let r_id = - 1 , r_size = 0 , i ; if ( rs . length < 1 ) { return null ; } for ( i = 0 ; i < rs . length ; i ++ ) { if ( null === rs [ i ] ) { continue ; } // Set on first valid range and subsequently larger ranges if ( - 1 === r_id || rs [ i ] . indices [ 1 ] - rs [ i ] . indices [ 0 ] > r_size ) { r_id = i ; r_size = rs [ i ] . indices [ 1 ] - rs [ i ] . indices [ 0 ] ; } } return r_id ; }
Takes an array of range objects and returns the array index
for the first range with the longest span, meaning that if
there are multiple longest ranges with the same indices, the
index for the first one in the array will be returned.

@param {Array} rs Range objects, having at least { indices: [ start, end ] }
@returns {Number|null} Index in the range array with the longest span between indices or null if no valid ranges
Takes an array of range objects and returns the array index for the first range with the longest span meaning that if there are multiple longest ranges with the same indices the index for the first one in the array will be returned .