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.
- Host: GitHub
- URL: https://github.com/artdecocode/indicatrix
- Owner: artdecocode
- License: mit
- Created: 2018-11-11T19:47:49.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-01-28T19:44:16.000Z (almost 6 years ago)
- Last Synced: 2025-02-08T14:41:54.744Z (11 months ago)
- Language: JavaScript
- Homepage: https://www.artd.eco
- Size: 63.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# indicatrix
[](https://www.npmjs.com/package/indicatrix)
`indicatrix` Is A CLI Loading Indicator Implemented As A Changing Ellipsis (Triple-Dot).

```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™ 2020