Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Commit eb99e80

Browse files
committed
publish @secman/spinner package
1 parent e08d778 commit eb99e80

File tree

12 files changed

+1948
-0
lines changed

12 files changed

+1948
-0
lines changed

example.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// import spinner
2+
import { spnr as spinner } from "./main.js";
3+
4+
const x = spinner("hi").start();

lib/restore-cursor.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as process from "process";
2+
import { onetime } from "../tools/onetime"
3+
import signalExit from "signal-exit";
4+
5+
export const restoreCursor = onetime(() => {
6+
signalExit(
7+
() => {
8+
process.stderr.write("\u001B[?25h");
9+
},
10+
{ alwaysLast: true }
11+
);
12+
});

lib/spinners.cjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const spinners = Object.assign({}, require("./spinners.json"));
2+
3+
const spinnersList = Object.keys(spinners);
4+
5+
Object.defineProperty(spinners, "random", {
6+
get() {
7+
const randomIndex = Math.floor(Math.random() * spinnersList.length);
8+
const spinnerName = spinnersList[randomIndex];
9+
return spinners[spinnerName];
10+
},
11+
});
12+
13+
module.exports = spinners;

0 commit comments

Comments
 (0)