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 🙏

© 2025 – Pkg Stats / Ryan Hefner

platy

v1.0.2

Published

A simple animation library for the terminal

Readme

Platy.js

  .^====^.
 =( ^__^ )= ~ 'A simple animation library for the terminal!'
  /      \\
+( |    | )//

Could be used to make some fun notification animations in your build scripts ;)

Basic Usage

const Platy = require('platy');

// Create a new instance of the stage that will render and display animations
const stage = new Platy.Stage('main');

// Create a character
const cat   = new Platy.Character('cat');

// Crummy fat lazy cat animation
const lazyCat = new Platy.Animation('idleCat', [ // An array of frames
`
  .^====^.
 =( o__o )=
  /      \\
+( |    | )//
`,
`
  .^====^.
 =( ^--^ )=
  /      \\
+( |    | )//
`
]);


// Crummy fat sleepy cat animation
const sleepyCat = new Platy.Animation('sleepyCat', [
  `
  .^====^.
 =( - o- )=
  /      \\
+( |    | )//
`,
`
  .^====^.
 =( - .- )=
  /      \\
+( |    | )//
`
]);


// Next create some actions for our Cat, including an animation and text to speak.
cat.on('smile', lazyCat, 'Hello,\nWorld!');
cat.on('sleep', sleepyCat, 'zzz...');

// Play our cat's smile
stage.play( cat.action('smile') );

// Change animation after 5 seconds
setTimeout(function(){

    // Nothing is happening so I'm going to take a nap...
    stage.play( cat.action('sleep') );

}, 5000);

Overview

Platy.js exports a collection of classes needed for displaying animations:

| Class | Description | | --------------- | ----------- | | Platy.Stage | Will handle a character's action and display it on an interface, including looping through each frame of the animation and rendering it with any text if provided. | | Platy.Character | Stores a collection of actions for a character. | | Platy.Animation | Stores a sequence of frames for an animation where each frame is a string of characters to print to the interface when rendered. |

Platy.Stage methods:

Stage.constructor(name[, readline])

Returns an instance of the stage. Pass the stage name and optionally the readline interface to print animations.

Stage.clear()

The method clears the interface of the last frame printed to the interface. Note: this will reset the stage's width and height to 0.

Stage.render(action)

Renders a Character Action to the interface. The method will get the action animation's current frame and compile it with optional text before printing it to the terminal.

Stage.play(name[, duration])

Loops through each frame of an action's animation on intervals based on Stage.fps and passes the action to Stage.render() after the next frame is selected. This method will return a promise that resolves with 'stop' when the animation stops, and 'pause' when the animation is paused. If the optional duration parameter is passed (in seconds), the Stage.stop() method will be called after the time limit.

Stage.pause()

Stops the current animation loop without clearing the stage and resolves the Promise object returned by Stage.play with 'pause'

Stage.stop()

Stops the current animation loop, clears the stage and resets the current action's animation to the first frame.

Platy.Stage properties

| Property | Default | Description | | -------------- | ------- | ----------- | | Stage.fps | 1 | The number of loops per second | | Stage.spacer | ' ~ ' | The divider between the animation frame and text. | | Stage.width | 0 | The width of the stage as the compiled string length. Automatically calculated when Stage.render() is called. | | Stage.height | 0 | The height of the stage as the max number of lines. Also calculated on Stage.render() | | Stage.readline | readline.Interface | The interface to write the compiled actions to. |

Platy.Character methods

Character.constructor(name)

Pass a name for the character to have.

Character.on(name, animation[, say])

Creates an Action that can be passed to the Stage. Pass a name to reference the action with and a Platy.Animation instance to render when the action is compiled. Optionally pass a string as the say parameter to display as a message alongside the animation.

Character.action(name)

Returns an action that can then be passed to Stage.play(action).

Platy.Animation methods

Animation.constructor(name[, frames])

Pass a reference name and optionally an array of strings which will be converted into frames

Animation.addFrame(frame[, location][, length])

Pass a string as a single frame to add to the animation. Optionally add the location to insert the frame into the animation's timeline and the length of the frame. Note: Existing frames can be overriden if they are located at the same point where the new frame is being inserted. By default, the new frame is inserted at the end of the animation's timeline and will take up a single slot.

Animation.current()

Returns the current frame

Animation.next()

Moves the current frame pointer to the next frame or resets to the first frame when the end of the timeline is reached.

Animation.prev()

Moves the current frame pointer to the previous frame or moves to the last frame when the start of the timeline is reached.

Animation.reset()

Sets the current frame to the beginning of the animation's timeline.

Animation.end()

Sets the current frame to the end of the animation's timeline.

Platy.Animation properties

| Property | Default | Description | | --------------- | ------- | ----------- | | Stage.frames | [] | Direct access to the animation's sequence of frames | | Stage.pointer | 0 | The current frame indicator (first frame starts at 0)