2022-01-21 08:28:41 +00:00
|
|
|
# cli-cursor [![Build Status](https://travis-ci.org/sindresorhus/cli-cursor.svg?branch=master)](https://travis-ci.org/sindresorhus/cli-cursor)
|
|
|
|
|
|
|
|
> Toggle the CLI cursor
|
|
|
|
|
|
|
|
The cursor is [gracefully restored](https://github.com/sindresorhus/restore-cursor) if the process exits.
|
|
|
|
|
|
|
|
|
|
|
|
## Install
|
|
|
|
|
|
|
|
```
|
2022-05-29 09:24:36 +00:00
|
|
|
$ npm install --save cli-cursor
|
2022-01-21 08:28:41 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```js
|
|
|
|
const cliCursor = require('cli-cursor');
|
|
|
|
|
|
|
|
cliCursor.hide();
|
|
|
|
|
|
|
|
const unicornsAreAwesome = true;
|
|
|
|
cliCursor.toggle(unicornsAreAwesome);
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
### .show([stream])
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
### .hide([stream])
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
### .toggle(force, [stream])
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
`force` is useful to show or hide the cursor based on a boolean.
|
2022-01-21 08:28:41 +00:00
|
|
|
|
|
|
|
#### stream
|
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
Type: `Stream`<br>
|
2022-01-21 08:28:41 +00:00
|
|
|
Default: `process.stderr`
|
|
|
|
|
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
## License
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2022-05-29 09:24:36 +00:00
|
|
|
MIT © [Sindre Sorhus](https://sindresorhus.com)
|