Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-peco

minidonut684MIT0.1.6TypeScript support: included

Peco (Simplistic interactive filtering tool) NodeJS Binding

cli, command-line, command-line-tool, fuzzy, fuzzy-search, prompt, interactive, peco

readme

Node Peco

peco nodejs binding library

NOTE: external command peco is required. see peco installation

NPM github ci npm npm bundle size

example

Installation

yarn add node-peco

Usage

This package exports only one function named peco.

import { peco } from 'node-peco'; // or require('node-peco');

peco(['foo', 'bar', 'baz']).then(selected => console.log(selected));

You can pass option as a second argument

import { peco, PecoOption } from 'node-peco';

const pecoOption: PecoOption = {
  onCancel: 'reject',
  layout: 'bottom-up',
  selectionPrefix: '*',
  prompt: "Choose ->",
};

peco(['foo', 'bar', 'baz'], pecoOption).then(selected => console.log(selected));

for more examples, see examples

Option

There are two categories of option. One is js dependent:

key type description default
bin string peco binary command(or location path) "peco"
onCancel "reject" | "skip" specify behavior when received SIGINT "skip"
onError "reject" | "exit" specify behavior when peco exited with non-zero code "exit"

The other is peco command line option. See peco#command-line-options