npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fzf-ts

v1.1.1

Published

Typescript interface to fzf utility

Readme

fzf-ts

A TypeScript interface to the fzf command-line fuzzy finder.

Installation

As a CLI tool

npm install -g fzf-ts

As a library

npm install fzf-ts

Requirements

  • Node.js 14 or later
  • fzf must be installed on your system

Installing fzf

macOS (Homebrew):

brew install fzf

Linux (most distributions):

sudo apt install fzf

Other platforms: See the fzf installation guide

Usage

CLI usage

Use it just like you would use fzf - pipe data to it and capture the output:

cat file.txt | fzf-ts
ls | fzf-ts
find . -type f | fzf-ts --preview 'cat {}'
echo -e "line 1\nline 2\nline 3" | fzf-ts

All fzf command-line arguments are passed through directly to fzf.

Library usage

import { getUserSelection, checkIfFzfIsInstalled } from 'fzf-ts';

async function example() {
  // Optional: Check if fzf is available
  const fzfAvailable = await checkIfFzfIsInstalled();
  if (!fzfAvailable) {
    console.error('fzf is not installed');
    return;
  }

  const selection = await getUserSelection({
    items: [
      { display: 'Option 1', value: 1 },
      { display: 'Option 2', value: 2 },
    ],
    fzfArgs: ['--no-sort', '--ansi'], // Optional fzf arguments
    getPreview: async (item) => `Preview for ${item.display}`, // Optional preview function
  });

  console.log('Selected:', selection);
}

How it works

This library interfaces with the fzf command-line tool via:

  • stdout: Sending items to fzf's stdin
  • temporary files: Communicating selection state and preview content between the Node.js process and fzf

The preview functionality uses a polling mechanism with temporary files to provide dynamic previews as you navigate through items.

API

getUserSelection<T extends FzfSelection>(options)

Displays a list of items using fzf and returns the selected item.

Parameters

  • options.items: Array of items to select from
    • Each item must have a display property (string shown in the list)
    • Items can optionally have previewPrefix and previewSuffix strings
  • options.fzfArgs: Optional array of fzf command-line arguments
  • options.getPreview: Optional async function that returns a string preview for an item
    • Note: This function is called for each item as you navigate through the list
    • Can be slow operations like web requests - the preview will update when the async operation completes
    • Example from demo.ts:
      getPreview: async (item) => {
        await new Promise(resolve => setTimeout(resolve, 250)); // Simulate delay
        return `Preview for ${item.display}\n${JSON.stringify(item, null, 2)}`;
      }
  • options.debounceMs: Optional debounce delay in milliseconds before calling getPreview (defaults to 0)
    • Useful when getPreview makes expensive calls like web requests
    • Prevents rapid calls when quickly navigating through items

Returns

A promise that resolves to the selected item, or undefined if no selection was made.

checkIfFzfIsInstalled()

Checks if fzf is installed on the system.

Returns

A promise that resolves to true if fzf is installed, false otherwise.