1/* Built-in method references for those with the same name as other `lodash` methods. */ 2var nativeMax = Math.max, 3 nativeMin = Math.min; 4 5/** 6 * Gets the view, applying any `transforms` to the `start` and `end` positions. 7 * 8 * @private 9 * @param {number} start The start of the view. 10 * @param {number} end The end of the view. 11 * @param {Array} transforms The transformations to apply to the view. 12 * @returns {Object} Returns an object containing the `start` and `end` 13 * positions of the view. 14 */ 15function getView(start, end, transforms) { 16 var index = -1, 17 length = transforms.length; 18 19 while (++index < length) { 20 var data = transforms[index], 21 size = data.size; 22 23 switch (data.type) { 24 case 'drop': start += size; break; 25 case 'dropRight': end -= size; break; 26 case 'take': end = nativeMin(end, start + size); break; 27 case 'takeRight': start = nativeMax(start, end - size); break; 28 } 29 } 30 return { 'start': start, 'end': end }; 31} 32 33module.exports = getView; 34