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 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-fzf

v0.11.0

Published

fzf ( junegunn/fzf ) inspired cli utility for node

Downloads

284,716

Readme

npm npm npm

node-fzf

fzf inspired fuzzy CLI list selection 🎀

Easy to use

CLI usage

npm install -g node-fzf

# by default (TTY mode) will glob list of current dir files
nfzf

# using pipes
find . | nfzf | xargs cat | less
alias merge="git branch | nfzf | xargs git merge"
alias checkout="git branch | nfzf | xargs git checkout"

API usage

promises
const nfzf = require( 'node-fzf' )

// if you only care about r.query
// nfzf.getInput( label )

const opts = {
  /* required */
  list: [ 'whale', 'giraffe', 'monkey' ],

  /* optional (and defaults) */
  // filtering mode (user can change modes by pressing ctrl-s)
  mode: 'fuzzy' || 'normal',

  // prefill user input
  prefill: '',

  // text before each displayed line, list index supplied as arg
  prelinehook: function ( index ) { return '' }

  // text after each displayed line, list index supplied as arg
  postlinehook: function ( index ) { return '' }
}

;( async function () {
  // opens interactive selection CLI
  // note! this messes with stdout so if you are
  // writing to stdout at the same time it will look a bit messy..
  const result = await nfzf( opts )

  const { selected, query } = result

  if( !selected ) {
    console.log( 'No matches for:', query )
  } else {
    console.log( selected.value ) // 'giraffe'
    console.log( selected.index ) // 1
    console.log( selected.value === opts.list[ selected.index ] ) // true
  }
} )()

// can also add more items later..
setInterval( function () {
  opts.list.push( 'foobar' )

  // an .update method has been attached to the object/array
  // that you gave to nfzf( ... )
  opts.update( list )
}, 1000 )
callbacks
const nfzf = require( 'node-fzf' )

// if you only care about r.query
// nfzf.getInput( label, callback )

const list = [ 'whale', 'giraffe', 'monkey' ]

// opens interactive selection CLI
// note! this messes with stdout so if you are
// writing to stdout at the same time it will look a bit messy..
const api = nfzf( list, function ( result ) {
  const { selected, query } = result
  if( !selected ) {
    console.log( 'No matches for:', query )
  } else {
    console.log( selected.value ) // 'giraffe'
    console.log( selected.index ) // 1
    console.log( selected.value === list[ selected.index ] ) // true

    // the api is a reference to the same argument0 object
    // with an added .update method attached.
    console.log( list === api ) // true
    console.log( list.update === api.update ) // true
  }

} )

// can also add more items later..
setInterval( function () {
  list.push( 'foobar' )
  api.update( list )
}, 1000 )

Keyboard

<ctrl-j>,<ctrl-n>,down        scroll down
<ctrl-k>,<ctrl-p>,up          scroll up

<ctrl-d>                      scroll down by page size
<ctrl-u>                      scroll up by page size

<ctrl-a>                      jump to start of input
<ctrl-e>                      jump to end of input

<esc>,<ctrl-q>,<ctrl-c>       cancel

<return>,<ctrl-m>             trigger callback/promise with current selection and exit

<ctrl-w>                      delte last word from input

<ctrl-b>                      jump back a word
<ctrl-f>                      jump forward a word

<backspace>                   delete last input character

<ctrl-s>                      switch between modes (fuzzy, normal)

About

fzf inspired fuzzy CLI list selection thing for node.

Why

easy fuzzy list selection UI for NodeJS CLI programs.

How

Mostly cli-color for dealing with the terminal rendering and ttys to hack the ttys to simultaneously read from non TTY stdin and read key inputs from TTY stdin -> So that we can get piped input while also at the same time receive and handle raw keyboard input.

Used by

yt-play

yt-search

Alternatives

fzf even though it doesn't work in NodeJS directly is all-in-all a better tool than this piece of crap :) Highly recommend~

ipt - similar node based solution

Test

npm test