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

interflow

v1.0.2

Published

A package for simple console interfaces

Downloads

3

Readme

Project Title

A brief description of what this project does and who it's for

Interflow

A npm package for console control.

Installation

Install interflow with npm

  npm install interflow

Features

  • logging with timestamp, warning, info, error, debug and success
  • logging with colors
  • string input, bool input and option input
  • key event system
  • cursor control: setPosition, getPosition
  • clear console/line
  • customizable progressbar

Usage/Examples

Hello World

import {Interflow} from 'interflow'
import {stdin, stdout} from 'node:process'

async function main() {
  const interflow = new Interflow(stdin, stdout)
  interflow.log("Hello World")
}

main()

Output

Hello World

Input

const interflow = new Interflow(stdin, stdout)

await interflow.input("Whats your name? ", (input) => {
  interflow.log("Hello", input)
})

Output

What is your name? (Interflow)
Hello (Interflow)

Colors

import {Interflow, InterflowColor} from 'interflow'

const interflow = new Interflow(stdin, stdout)

interflow.log(
  InterflowColor.red("Something in red!")
)

Output

Something in red! (it's red trust me)

Key input

const interflow = new Interflow(stdin, stdout)

interflow.on("key", (key) => {
  interflow.log(key.bytes, key.code(), key.value())
})

Output

(key press "a")
97 a a

(key press "arrow up")
27,91,65 up (value is empty since its not a visible char)

Documentation

Interflow

Config

const interflow = new Interflow(stdin, stdout, {
  timestamps: false,
  debugConfig: {
    showLineNumbers: false,
    showLineNumbersFromAbsolute: false,
  }
})

Log

// normal log
interflow.log("hello world")

// with multiple objects
interflow.log("hello", "world")

// info
interflow.info("some info")

// warning
interflow.warning("some warning")

// error
interflow.error("some error")

// debug
interflow.debug("some debug")

// success
interflow.success("some success")

Input

String

await interflow.input("Whats your name?", (input) => {
    interflow.log("Hello", input)
})
Whats your name? (Interflow)
Hello (Interflow)

Bool

await interflow.boolInput("Would you like to continue?", (input) => {
    interflow.log("You chose", input)
})
Would you like to continue? (Y/n)
You chose (true)

Multiple options

let options = ["option 2", "option 2", "option 3"]

await interflow.chooseInput("Choose an option?", options, (input) => {
    interflow.log("You chose", input)
})
Choose an option? [option 1] [option 2] [option 3]
You chose (option 2)

Events

Key

interflow.on("key", (key) => {
    interflow.log(key.bytes, key.code(), key.value())
})

Cursor Control

interflow.goto(x, y, from_absolute)
// absolute is from very top
// relative is from first log

interflow.up(n_lines)
interflow.down(n_lines)

Console

interflow.clear() // Clear whole console

interflow.clearLine(line, from_absolute)
// absolute is from very top
// relative is from first log

InterflowColor

Usage

interflow.log(
    InterflowColor.green("You made it until here!")
)

Colors

Foreground

  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • black
  • redBright
  • greenBright
  • yellowBright
  • blueBright
  • magentaBright
  • cyanBright
  • whiteBright

Background

  • bgRed
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgBlack
  • bgRedBright
  • bgGreenBright
  • bgYellowBright
  • bgBlueBright
  • bgMagentaBright
  • bgCyanBright
  • bgWhiteBright

Fonts

  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikeThrough

InterflowProgressbar

Basic Usage

const interflow = new Interflow(stdin, stdout);

const bar = new InterflowProgressBar(interflow)
    .setLabel('Loading')
    .setUseBlocks(true)
    .setBarLength(50)
    .setMax(1000);

for (let i = 0; i < 1000; i++) {
    bar.tick();
    await interflow.sleep(100);

    if (i % 20 === 0) {
        interflow.log("Index", i)
    }
}
Loading [█████████████                                     ] (27%)
Index 0
Index 20

Authors