Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[6a3a178] | 1 | /* Built-in method references for those with the same name as other `lodash` methods. */
|
---|
| 2 | var 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 | */
|
---|
| 15 | function 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 |
|
---|
| 33 | module.exports = getView;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.