版博士V2.0程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

21 lignes
727 B

  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. module.exports = (cursor, total, maxVisible) => {
  12. maxVisible = maxVisible || total;
  13. let startIndex = Math.min(total - maxVisible, cursor - Math.floor(maxVisible / 2));
  14. if (startIndex < 0) startIndex = 0;
  15. let endIndex = Math.min(startIndex + maxVisible, total);
  16. return {
  17. startIndex,
  18. endIndex
  19. };
  20. };