| Conditions | 3 |
| Paths | 3 |
| Total Lines | 40 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | export const getCurrentRecords = ( |
||
| 2 | dataSource, |
||
| 3 | pageIndex, |
||
| 4 | pageSize, |
||
| 5 | infinite, |
||
| 6 | viewableIndex, |
||
| 7 | viewableCount, |
||
| 8 | bufferMultiplier |
||
| 9 | ) => { |
||
| 10 | |||
| 11 | if (!dataSource) { |
||
| 12 | return {}; |
||
| 13 | } |
||
| 14 | |||
| 15 | if (infinite) { |
||
| 16 | const start = Math.max( |
||
| 17 | viewableIndex - viewableCount * bufferMultiplier, |
||
| 18 | 0 |
||
| 19 | ); |
||
| 20 | |||
| 21 | const end = Math.min( |
||
| 22 | viewableIndex + viewableCount * (bufferMultiplier + 1), |
||
| 23 | dataSource.currentRecords.length |
||
| 24 | ); |
||
| 25 | |||
| 26 | return { |
||
| 27 | data: dataSource.data.slice(start, end), |
||
| 28 | startIndex: start, |
||
| 29 | endIndex: end |
||
| 30 | }; |
||
| 31 | } |
||
| 32 | |||
| 33 | return { |
||
| 34 | data: dataSource.data.slice( |
||
| 35 | pageIndex * pageSize, (pageIndex + 1) * pageSize |
||
| 36 | ), |
||
| 37 | startIndex: null, |
||
| 38 | endIndex: null |
||
| 39 | }; |
||
| 40 | }; |
||
| 41 |