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

fp-tetris

v0.0.20

Published

library for fp-tetris-game

Readme

fp-tetris

Tetris game library and CLI — also used by fp-tetris-game

Just run

npx fp-tetris

fp-tetris demo

Run with source

git clone https://github.com/afrontend/fp-tetris.git
cd fp-tetris
npm install
npm start

CLI options

| Option | Description | |--------|-------------| | -f, --full | Use full terminal size for the board |

Controls

Tip: Press h during the game to show/hide the key list. The piece freezes while the help is open.

| Key | Action | |-----|--------| | | Move piece left / right | | | Move piece down | | | Rotate piece | | Space | Hard drop | | p | Pause / resume | | h | Show / hide in-game key help | | r | Rotate the background panel | | s | Save current state | | l | Load saved state | | q / Ctrl+C | Quit |

How fp-tetris uses fp-panel

fp-tetris uses fp-panel as its 2D grid engine. Here is the step-by-step flow:

Step 1 — Create the board

p.createPanel(rows, columns) builds the background grid. Each cell is initialized with p.createItem(color).

const bgPanel = p.createPanel(20, 10);

Step 2 — Spawn a tetromino

Each piece is painted onto a small panel with p.paint(panel, cells, color), then centered with p.adjustToCenter(panel).

const toolPanel = _.flow([createPanel, paintT, p.adjustToCenter])();
// paintT places the T-piece cells; adjustToCenter shifts the panel to the middle of the board

Step 3 — Move and rotate

The active piece panel is repositioned each frame using p.left(), p.right(), p.down(), or p.rotate(). Before applying the move, collision is checked:

if (!p.isOnTheLeftEdge(toolPanel) && !p.isOverlap(bgPanel, p.left(toolPanel))) {
  toolPanel = p.left(toolPanel);
}

Edge detection helpers (p.isOnTheLeftEdge, p.isOnTheRightEdge, p.isOnTheBottomEdge) prevent the piece from leaving the board.

Step 4 — Land and clear rows

When the piece can no longer move down, it is merged into the background with p.add([bgPanel, toolPanel]). Full rows (no blank cells) are then removed and replaced with empty rows at the top.

const newBgPanel = p.add([bgPanel, toolPanel]);
// then filter out full rows and prepend empty ones

Step 5 — Render

To draw the current frame, the two panels are merged again with p.add() and each cell is inspected with p.isBlankItem().

const frame = p.add([bgPanel, toolPanel]);
frame.forEach(row => {
  console.log(row.map(cell => p.isBlankItem(cell) ? '.' : '■').join(' '));
});

Tetrominoes

| Piece | Color | |-------|-------| | O | Yellow | | I | Cyan | | T | Magenta | | J | White | | L | Blue | | S | Green | | Z | Red |

Updating the Demo GIF

Regenerates the terminal preview automatically.

# Install dependencies (first time only)
brew install asciinema
brew install agg
brew install gh && gh auth login

# Generate and upload to GitHub Releases
npm run demo-gif

npm run demo-gif steps:

  1. scripts/autoplay.js — autoplays the game and exits automatically
  2. asciinema rec — records terminal output to demo.cast
  3. agg — converts demo.castdemo.gif
  4. gh release upload — uploads to the demo-assets GitHub Release tag
  5. README.md — updates the GIF URL to the GitHub Releases path

Pushing to the master branch triggers .github/workflows/demo.yml, which runs all of the above automatically.

License

MIT © Bob Hwang