Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

indicatrix

artdecocode67MIT1.4.1

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

indicatrix, load, loading, cli, terminal, console, ellipsis, triple dot, dots, indicator, indication, ui, wait

readme

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.

  • <kbd>text*</kbd> string: The text to display in the CLI.
  • <kbd>promise</kbd> (!Promise<T> | function(...): !Promise<T>): The promise or an async function that returns the promise.
  • <kbd>options</kbd> !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

Art Deco © Art Deco™ 2020

changelog

28 January 2020

1.4.1

  • [fix] Add INDICATRIX_PLACEHOLDER to externs to prevent renaming.

12 September 2019

1.4.0

  • [feature] Support INDICATRIX_PLACEHOLDER env variable for Documentary.

2 August 2019

1.3.0

  • [feature] Add generics template JSDoc annotations.
  • [package] Compile with Depack.

25 April 2019

1.2.0

  • [externs] Add externs and namespace to the types.

2 April 2019

1.1.0

  • [package] Add module field.

16 November 2018

1.0.0