Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/saehun/node-peco
peco(https://github.com/peco/peco) nodejs binding library
https://github.com/saehun/node-peco
cli command-line fuzzy-search nodejs peco typescript
Last synced: about 2 months ago
JSON representation
peco(https://github.com/peco/peco) nodejs binding library
- Host: GitHub
- URL: https://github.com/saehun/node-peco
- Owner: saehun
- License: mit
- Created: 2020-10-10T21:50:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T15:12:59.000Z (almost 2 years ago)
- Last Synced: 2024-10-13T11:09:02.596Z (2 months ago)
- Topics: cli, command-line, fuzzy-search, nodejs, peco, typescript
- Language: TypeScript
- Homepage:
- Size: 494 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
## Node Peco
[peco](https://github.com/peco/peco) nodejs binding library> NOTE: external command `peco` is required. see [peco installation](https://github.com/peco/peco#installation)
![NPM](https://img.shields.io/npm/l/node-peco)
![github ci](https://github.com/minidonut/node-peco/workflows/CI/badge.svg)
[![npm](https://img.shields.io/npm/v/node-peco)](https://www.npmjs.com/package/node-peco)
![npm bundle size](https://img.shields.io/bundlephobia/minzip/node-peco?label=size)## Installation
```
yarn add node-peco
```## Usage
This package exports only one function named `peco`.
```ts
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
```ts
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](https://github.com/minidonut/node-peco/tree/master/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](https://github.com/peco/peco#command-line-options)