lib/actions/select-item.js
function getPreviousRange(ranges, anchor) {
	for (let i = 0; i < ranges.length; i++) {
		if (anchor.isEqual(ranges[i])) {
			// NB may return `undefined`, which is totally fine and means that
			// we should move to next element
			return ranges[i - 1];
		}
	}

	// Keep ranges which are not on the left of given selection
	ranges = ranges.filter(r => r.end.isLessThanOrEqual(anchor.start));

	return last(ranges);
}
function getPreviousRange(ranges, anchor) {
	for (let i = 0; i < ranges.length; i++) {
		if (anchor.isEqual(ranges[i])) {
			// NB may return `undefined`, which is totally fine and means that
			// we should move to next element
			return ranges[i - 1];
		}
	}

	// Keep ranges which are not on the left of given selection
	ranges = ranges.filter(r => r.end.isLessThanOrEqual(anchor.start));

	return last(ranges);
}
function getPreviousRange ( ranges , anchor ) { for ( let i = 0 ; i < ranges . length ; i ++ ) { if ( anchor . isEqual ( ranges [ i ] ) ) { // NB may return `undefined`, which is totally fine and means that // we should move to next element return ranges [ i - 1 ] ; } } // Keep ranges which are not on the left of given selection ranges = ranges . filter ( r => r . end . isLessThanOrEqual ( anchor . start ) ) ; return last ( ranges ) ; }
Tries to find range that equals given `anchor` range in `ranges` and returns
previous one. Otherwise returns previous to given `anchor` range
@param  {Range[]} ranges
@param  {Range}   anchor
@return {Range}   May return `undefined` if there’s no valid next range
Tries to find range that equals given anchor range in ranges and returns previous one . Otherwise returns previous to given anchor range