main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1022 bytes
|
Line | |
---|
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 | export default getView;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.