source: frontend/node_modules/prompts/lib/util/entriesToDisplay.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 721 bytes
Line 
1'use strict';
2
3/**
4 * Determine what entries should be displayed on the screen, based on the
5 * currently selected index and the maximum visible. Used in list-based
6 * prompts like `select` and `multiselect`.
7 *
8 * @param {number} cursor the currently selected entry
9 * @param {number} total the total entries available to display
10 * @param {number} [maxVisible] the number of entries that can be displayed
11 */
12module.exports = (cursor, total, maxVisible) => {
13 maxVisible = maxVisible || total;
14
15 let startIndex = Math.min(total- maxVisible, cursor - Math.floor(maxVisible / 2));
16 if (startIndex < 0) startIndex = 0;
17
18 let endIndex = Math.min(startIndex + maxVisible, total);
19
20 return { startIndex, endIndex };
21};
Note: See TracBrowser for help on using the repository browser.