Socket
Socket
Sign inDemoInstall

terminal-paginator

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terminal-paginator - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

17

index.js

@@ -7,3 +7,3 @@ 'use strict';

/**
* The paginator keeps track of a pointer index in a list
* The paginator keeps track of a position index in a list
* and returns a subset of the choices if the list is too

@@ -16,5 +16,6 @@ * long.

this.options = options || {};
this.footer = this.options.footer || '(Move up and down to reveal more choices)';
this.firstRender = true;
this.lastIndex = 0;
this.pointer = 0;
this.position = 0;
}

@@ -34,7 +35,7 @@

// Move the pointer when a down keypress is entered, and limit
// Move the position when a down keypress is entered, and limit
// it to approximately half the length of the limit to keep the
// pointer the middle of the visible list
if (this.pointer < middle && this.lastIndex < selected && selected - this.lastIndex < limit) {
this.pointer = Math.min(middle, this.pointer + selected - this.lastIndex);
// position the middle of the visible list
if (this.position < middle && this.lastIndex < selected && selected - this.lastIndex < limit) {
this.position = Math.min(middle, this.position + selected - this.lastIndex);
}

@@ -47,3 +48,3 @@

var infinite = lines.concat(lines).concat(lines).filter(Boolean);
var topIndex = Math.max(0, selected + lines.length - this.pointer);
var topIndex = Math.max(0, selected + lines.length - this.position);

@@ -61,3 +62,3 @@ if (this.options.radio === true && this.firstRender) {

visible += '\n';
visible += log.dim('(Move up and down to reveal more choices)');
visible += log.dim(this.footer);

@@ -64,0 +65,0 @@ // ensure that output has a leading newline, so that the first

{
"name": "terminal-paginator",
"description": "Paginator used for rendering lists or choices for prompts in the terminal.",
"version": "1.0.2",
"version": "1.1.0",
"homepage": "https://github.com/enquirer/terminal-paginator",

@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc