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

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

Fix frontend appearance

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