summaryrefslogtreecommitdiff
path: root/node_modules/cli-cursor/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/cli-cursor/index.js')
-rw-r--r--node_modules/cli-cursor/index.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/cli-cursor/index.js b/node_modules/cli-cursor/index.js
new file mode 100644
index 0000000..710c405
--- /dev/null
+++ b/node_modules/cli-cursor/index.js
@@ -0,0 +1,35 @@
+'use strict';
+const restoreCursor = require('restore-cursor');
+
+let isHidden = false;
+
+exports.show = (writableStream = process.stderr) => {
+ if (!writableStream.isTTY) {
+ return;
+ }
+
+ isHidden = false;
+ writableStream.write('\u001B[?25h');
+};
+
+exports.hide = (writableStream = process.stderr) => {
+ if (!writableStream.isTTY) {
+ return;
+ }
+
+ restoreCursor();
+ isHidden = true;
+ writableStream.write('\u001B[?25l');
+};
+
+exports.toggle = (force, writableStream) => {
+ if (force !== undefined) {
+ isHidden = force;
+ }
+
+ if (isHidden) {
+ exports.show(writableStream);
+ } else {
+ exports.hide(writableStream);
+ }
+};