aboutsummaryrefslogtreecommitdiff
path: root/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js
diff options
context:
space:
mode:
authorNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
committerNevena Bojovic <nenabojov@gmail.com>2022-03-01 22:05:25 +0100
commit6555fb80fdd8f6a5d201efadec3189d1244830a0 (patch)
treec1aa1c5aedc634ad1ea7fad4847884d559b51290 /sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js
parent7d3640f824f46490b47bd95f1c5a16644f712068 (diff)
Izbrisala bin, obj i node-modules.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js')
-rw-r--r--sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js78
1 files changed, 0 insertions, 78 deletions
diff --git a/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js b/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js
deleted file mode 100644
index 767bf672..00000000
--- a/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/paginator.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'use strict';
-
-const _ = {
- sum: require('lodash/sum'),
- flatten: require('lodash/flatten'),
-};
-const chalk = require('chalk');
-
-/**
- * The paginator returns a subset of the choices if the list is too long.
- */
-
-class Paginator {
- constructor(screen, options = {}) {
- const { isInfinite = true } = options;
- this.lastIndex = 0;
- this.screen = screen;
- this.isInfinite = isInfinite;
- }
-
- paginate(output, active, pageSize) {
- pageSize = pageSize || 7;
- let lines = output.split('\n');
-
- if (this.screen) {
- lines = this.screen.breakLines(lines);
- active = _.sum(lines.map((lineParts) => lineParts.length).splice(0, active));
- lines = _.flatten(lines);
- }
-
- // Make sure there's enough lines to paginate
- if (lines.length <= pageSize) {
- return output;
- }
- const visibleLines = this.isInfinite
- ? this.getInfiniteLines(lines, active, pageSize)
- : this.getFiniteLines(lines, active, pageSize);
- this.lastIndex = active;
- return (
- visibleLines.join('\n') +
- '\n' +
- chalk.dim('(Move up and down to reveal more choices)')
- );
- }
-
- getInfiniteLines(lines, active, pageSize) {
- if (this.pointer === undefined) {
- this.pointer = 0;
- }
- const middleOfList = Math.floor(pageSize / 2);
- // Move the pointer only when the user go down and limit it to the middle of the list
- if (
- this.pointer < middleOfList &&
- this.lastIndex < active &&
- active - this.lastIndex < pageSize
- ) {
- this.pointer = Math.min(middleOfList, this.pointer + active - this.lastIndex);
- }
-
- // Duplicate the lines so it give an infinite list look
- const infinite = _.flatten([lines, lines, lines]);
- const topIndex = Math.max(0, active + lines.length - this.pointer);
-
- return infinite.splice(topIndex, pageSize);
- }
-
- getFiniteLines(lines, active, pageSize) {
- let topIndex = active - pageSize / 2;
- if (topIndex < 0) {
- topIndex = 0;
- } else if (topIndex + pageSize > lines.length) {
- topIndex = lines.length - pageSize;
- }
- return lines.splice(topIndex, pageSize);
- }
-}
-
-module.exports = Paginator;