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

ttying

v1.0.1

Published

a tiny cli interactive library, help you accept commands in node app runtime

Downloads

2

Readme

ttying

ttying is a simple cli interactive library, you declare your shortcut config, when pressed key matched, shortcut action works.

npm package Build Status Downloads Issues Commitizen Friendly Semantic Release

Install

npm install ttying
yarn add ttying
pnpm add ttying

Usage

import ttying from 'ttying';

const ttyingInstance = ttying({
  shortcuts: [
    {
      trigger: 'p',
      description: 'Execute Task P',
      action() {
        console.log('Running Task P...');
        console.log('Task P Over');
      },
    },
    {
      trigger: 'r',
      description: 'Execute Task R',
      action() {
        console.log('Running Task R...');
        console.log('Task R Over');
      },
    },
    {
      trigger: 'h',
      description: 'Print helps',
      action() {
        ttyingInstance.help();
      },
    },
    {
      trigger: 'x',
      description: 'Exit Process',
      action() {
        process.exit();
      },
    },
  ],
});

ttyingInstance.start();

Options

shortcuts

type: ShortcutConfig[]

Shortcut config array

ShortcutConfig.trigger

type: string | readline.Key

Trigger could be a string or an object like readline.Key

ShortcutConfig.description

type: string

Description of current shortcut, it will be used to generate help content

ShortcutConfig.action

type: () => void | Promise<void>

The shortcut handler when trigger pressed.

helpFrequency

type: 'always' | 'once' | false

Determine when to print help content:

"always": print after every action over

"once": only print once when start

false: never print

helpContent

type: string

ttying auto generate help content from your shortcuts config, if you want override the default helps, you can use this option.

How to debug my key press ?

ttying use debug print debug info, so if you are not sure your trigger key, you can set DEBUG env to ttying and launch your cli app, then you can see the press key info in terminal.

write a example:

import ttying from 'ttying';

const ttyingInstance = ttying({
  shortcuts: [],
});

ttyingInstance.start();

run with DEBUG env:

DEBUG=ttying node app.js

press you key (such as F2), you will see:

ttying input: undefined, keyInfo: { sequence: '\x1BOQ', name: 'f2', ctrl: false, meta: false, shift: false, code: 'OQ' }, runningAction: false