Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { createPrompt } = require('@inquirer/core');
const { isUpKey, isDownKey, isSpaceKey, isNumberKey } = require('@inquirer/core/lib/key');
const Paginator = require('@inquirer/core/lib/Paginator');
const chalk = require('chalk');
const figures = require('figures');
const { cursorHide } = require('ansi-escapes');
module.exports = createPrompt(
readline => ({
onKeypress: (value, key, { cursorPosition = 0, choices }, setState) => {
let newCursorPosition = cursorPosition;
if (isUpKey(key) || isDownKey(key)) {
const offset = isUpKey(key) ? -1 : 1;
let selectedOption;
while (!selectedOption || selectedOption.disabled) {
newCursorPosition =
(newCursorPosition + offset + choices.length) % choices.length;
selectedOption = choices[newCursorPosition];
}
setState({ cursorPosition: newCursorPosition });
} else if (isSpaceKey(key)) {
setState({