node-fzf is a Node.js utility inspired by the `fzf` command-line fuzzy finder, providing an interactive CLI for list selection. It enables developers to integrate fuzzy searching capabilities into their Node.js applications, offering both a standalone CLI and a programmatic API. The current stable version is 0.14.0, published approximately 10 months ago, suggesting a maintenance or slow release cadence rather than rapid iteration. Key differentiators include its promise-based and callback-based API for integration, support for piping input and output with other CLI tools, and customizable display options like height and pre/post-line hooks. Unlike `fzf-node` which are direct Go bindings, `node-fzf` is a pure JavaScript implementation.
npm install node-fzfVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the promise-based API of `node-fzf` to present an interactive fuzzy selection list to the user, allowing them to pick an item from a predefined array. It showcases basic configuration, result handling, and interactive features.
Ensure all `stdout` writes and `stdin` reads are paused or buffered while `node-fzf` is running. Execute `node-fzf` in a separate child process or pipe its output carefully if integrating with other CLI tools.
Thoroughly test `node-fzf` functionality in your specific Windows environment. Report any issues to the GitHub repository. Consider using Windows Subsystem for Linux (WSL) for a more robust experience.
Always use `const nfzf = require('node-fzf')` for importing `node-fzf` in your Node.js projects, or ensure your build setup correctly handles CommonJS module interoperability if you are in an ESM project.Migrate from `nfzf(list, callback)` to `await nfzf(opts)` using the promise-based API for new development and refactoring, leveraging `async/await`.
Change the import statement to `const nfzf = require('node-fzf');`Ensure `node-fzf` has exclusive control over the terminal's `stdout` and `stdin` during its operation. Avoid `console.log` calls or other terminal output from your application while `nfzf` is running. Consider piping `node-fzf` output if mixing with other CLI tools.
Ensure you are calling `update()` on the *original list reference* that was passed to `nfzf`. For the object-based API, `opts.list.update(newList)` or if `api = nfzf(list, cb)`, then `api.update(newList)`.
Always check if `result.selected` is `null` or `undefined` after `nfzf` resolves. Provide appropriate user feedback or handle the `no selection` case gracefully in your application logic, as shown in the quickstart.