indicatrix

1.4.1 • Public • Published

indicatrix

npm version

indicatrix Is A CLI Loading Indicator Implemented As A Changing Ellipsis (Triple-Dot).

ellipsis demo

yarn add -E indicatrix

Table Of Contents

API

The package is available by importing its default function:

import indicatrix from 'indicatrix'

async indicatrix(
  text: string,
  promise: !Promise<T>|function(...*): !Promise<T>,
  options=: !Options,
): T

Will print the loading text and refresh the CLI line to show the ellipsis while the promise is loading.

  • text* string: The text to display in the CLI.
  • promise* (!Promise<T> | function(...*): !Promise<T>): The promise or an async function that returns the promise.
  • options !Options (optional): The optional options for the indicator, such as the refresh interval.

When called from the CLI application, indicatrix will print the supplied text and draw the ellipsis (. > .. > ... > .) animation at the end, until the promise is resolved.

Options: The optional options for the indicator, such as the refresh interval.

Name Type Description Default
interval number The interval with which to update the screen. 250
writable !(NodeJS.WriteStream | stream.Writable) The writable stream used for printing data with the .write method. process.stdout
import indicatrix from 'indicatrix'
 
(async () => {
  const res = await indicatrix('Please wait', async () => {
    await new Promise(r => setTimeout(r, 750))
    return 'OK'
  }, { interval: 100 })
  console.log(res)
})()
Please wait.
Please wait..
Please wait...
Please wait
Please wait.
Please wait..
Please wait...
Please wait
OK            

INDICATRIX_PLACEHOLDER env

When the INDICATRIX_PLACEHOLDER is set to anything other than 0, the package won't print the ... ellipsis, but append the static <INDICATRIX_PLACEHOLDER> string to the loading text instead. This is used by documentary to add an interactive placeholder:

Please wait
OK

Copyright

Art Deco © Art Deco™ 2020

Package Sidebar

Install

npm i indicatrix

Weekly Downloads

15

Version

1.4.1

License

MIT

Unpacked Size

15.7 kB

Total Files

16

Last publish

Collaborators

  • zvr