Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-status

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-status

A live status bar generator for node.js

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.5K
decreased by-9.52%
Maintainers
1
Weekly downloads
 
Created
Source

node-status

Makes a little stdout status bar. As simple or complex as you need.

npm install node-status
  • Config
  • Item Options
  • Item Methods
  • Patterns
  • Tokens

Example of custom patterns

image

Example of steps

image

Quickstart

var status = require('node-status')
var pizzas = status.addItem('pizza')

status.start()

pizzas.inc()
pizzas.inc(3)

Config

Status accepts the following config options on start():

  • invert: defaults to false. Inverts the colors of the bar.
  • interval: defaults to 250. Number of milliseconds per re-draw interval.
  • pattern: optional manual definition for status bar layout. See Patterns
status.start({
	invert: true,
	interval: 200,
	pattern: 'Doing work: {uptime}  |  {spinner.cyan}  |  {pizza.bar}'
})

Item Options

All item options are optional.

optiontypedefaultnotes
countnumber0Can specify a starting count if needed.
maxnumbernullWill cause 'count' type to display as count/max. Required for some display types. Can be a number or a function that returns a number.
customfunctionnulla function run when the pattern {<item>.custom} is used. Access this.count and this.max for values if needed. Must return a string.
precisionnumber2The precision used in percentages.
stepsArrayfalseAn array of strings that identify steps for the item. The count of the item identifies the current step.

Item Methods

methodnotes
inc( Number )Increases the count on the item by the desired amount. If no amount is specified, will increase by 1.
dec( Number )Decreases the count on the item by the desired amount. If no amount is specified, will decrease by 1.
doneStep( success:Boolean, message:String )A helper method for when using steps on an item. Will stamp the step to the screen with a ✔ when success is true, ✖ when false. An optional message can be added which will be appended to the display. See the gif above, or the examples/steps.js

Patterns

The pattern setting in status config can be used to layout your bar as you see fit, if the default doesn't suit you. Simply a string of tokens.

The pattern:

'Doing work: {uptime}  |  {spinner.cyan}  |  {pizza.bar}'

Would render as:

Doing work: 10s  |  ⠼  |  [▒▒▒▒▒▒----]

Tokens are specified as: {<token>[.color][.modifier]}.

All tokens support colorization with marak/colors.

Non-item tokens

tokenmodifiersnotes
uptimerenders the current uptime of the process.
spinnerspinner typesrenders a spinner. Any type available in cli-spinners can be used. Ex: {spinner.bouncingBall.cyan}

Item tokens

All items use their name as tokens. If you add an item named pizza, you can render it in the pattern with {pizza}. Simple.

Item type modifiers

The items have a number of types available to render.

typeexample
default5 or 5/10With no type specified, item is rendered as the count, or the count/max if max was specified.
percentage15.23%Renders a simple percentage, requires max to be set. Uses the precision setting to round the value.
customanythingRenders whatever is returned by the specified custom function.
bar[▒▒▒▒▒-----]Renders as a progress bar. Requires max to be set.
time15sUses the count as milliseconds and renders the value as a nicely formatted time.

Using Console.log alongside status

Right now, if you have to use console.log after the status bar has started, it can be a bit janky because the stdout line isn't cleared when a console.log is run.

You can utilize an extended console.log by adding this after requiring status.

console = status.console()

Keywords

FAQs

Package last updated on 23 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc