An open API service indexing awesome lists of open source software.

https://github.com/artdecocode/indicatrix

A CLI Loading Indicator Implemented As A Changing Elipsis.
https://github.com/artdecocode/indicatrix

Last synced: 11 months ago
JSON representation

A CLI Loading Indicator Implemented As A Changing Elipsis.

Awesome Lists containing this project

README

          

# indicatrix

[![npm version](https://badge.fury.io/js/indicatrix.svg)](https://www.npmjs.com/package/indicatrix)

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

![ellipsis demo](/images/ellipsis.gif)



```sh
yarn add -E indicatrix
```

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [API](#api)
- [`async indicatrix(text, promise, options=): T`](#async-indicatrixtext-stringpromise-promisetfunction-promisetoptions-options-t)
* [`Options`](#type-options)
- [`INDICATRIX_PLACEHOLDER` env](#indicatrix_placeholder-env)
- [Copyright](#copyright)



## API

The package is available by importing its default function:

```js
import indicatrix from 'indicatrix'
```



## async indicatrix(
  `text: string,`
  `promise: !Promise|function(...*): !Promise,`
  `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](#type-streamwritable)) | The writable stream used for printing data with the `.write` method. | `process.stdout` |

```js
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 `` string to the loading text instead. This is used by [documentary](https://artdecocode.com/documentary/) to add an interactive placeholder:

Please wait

OK



## Copyright




Art Deco


© Art Deco™ 2020