Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-spinner

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-spinner - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

license

10

dist/constants.js

@@ -1,14 +0,8 @@

"use strict";
/* MAIN */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SYMBOL_WARNING = exports.SYMBOL_SUCCESS = exports.SYMBOL_ERROR = exports.FRAMES_INTERVAL = exports.FRAMES = void 0;
const FRAMES = ['-', '\\', '|', '/'];
exports.FRAMES = FRAMES;
const FRAMES_INTERVAL = 40;
exports.FRAMES_INTERVAL = FRAMES_INTERVAL;
const SYMBOL_ERROR = '✖';
exports.SYMBOL_ERROR = SYMBOL_ERROR;
const SYMBOL_SUCCESS = '✔';
exports.SYMBOL_SUCCESS = SYMBOL_SUCCESS;
const SYMBOL_WARNING = '⚠';
exports.SYMBOL_WARNING = SYMBOL_WARNING;
/* EXPORT */
export { FRAMES, FRAMES_INTERVAL, SYMBOL_ERROR, SYMBOL_SUCCESS, SYMBOL_WARNING };

8

dist/index.d.ts

@@ -13,8 +13,2 @@ declare class Spinner {

}
declare const _default: typeof Spinner & {
default: typeof Spinner;
}
declare namespace _default {
export type type = Spinner;
}
export = _default;
export default Spinner;

@@ -1,11 +0,7 @@

"use strict";
/* IMPORT */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const kleur_1 = __importDefault(require("kleur"));
const stdin_blocker_1 = __importDefault(require("stdin-blocker"));
const tiny_cursor_1 = __importDefault(require("tiny-cursor"));
const constants_1 = require("./constants");
const utils_1 = require("./utils");
import Blocker from 'stdin-blocker';
import colors from 'tiny-colors';
import Cursor from 'tiny-cursor';
import { FRAMES, FRAMES_INTERVAL, SYMBOL_ERROR, SYMBOL_SUCCESS, SYMBOL_WARNING } from './constants.js';
import { writeLine } from './utils.js';
/* MAIN */

@@ -19,5 +15,5 @@ class Spinner {

this.render = () => {
const frame = constants_1.FRAMES[(this.iteration++) % constants_1.FRAMES.length];
const line = `${kleur_1.default.cyan(frame)} ${this.message}`;
(0, utils_1.writeLine)(line);
const frame = FRAMES[(this.iteration++) % FRAMES.length];
const line = `${colors.cyan(frame)} ${this.message}`;
writeLine(line);
};

@@ -28,5 +24,5 @@ this.start = (message) => {

this.message = message;
stdin_blocker_1.default.block();
tiny_cursor_1.default.hide();
this.intervalId = setInterval(this.render, constants_1.FRAMES_INTERVAL);
Blocker.block();
Cursor.hide();
this.intervalId = setInterval(this.render, FRAMES_INTERVAL);
};

@@ -37,9 +33,9 @@ this.update = (message) => {

this.warning = (message) => {
return this.stop(`${kleur_1.default.yellow(constants_1.SYMBOL_WARNING)} ${message}`);
return this.stop(`${colors.yellow(SYMBOL_WARNING)} ${message}`);
};
this.success = (message) => {
return this.stop(`${kleur_1.default.green(constants_1.SYMBOL_SUCCESS)} ${message}`);
return this.stop(`${colors.green(SYMBOL_SUCCESS)} ${message}`);
};
this.error = (message) => {
return this.stop(`${kleur_1.default.red(constants_1.SYMBOL_ERROR)} ${message}`);
return this.stop(`${colors.red(SYMBOL_ERROR)} ${message}`);
};

@@ -49,7 +45,7 @@ this.stop = (message = '') => {

return;
stdin_blocker_1.default.unblock();
tiny_cursor_1.default.show();
Blocker.unblock();
Cursor.show();
clearInterval(this.intervalId);
const line = message ? `${message}\n` : '';
(0, utils_1.writeLine)(line);
writeLine(line);
};

@@ -59,4 +55,2 @@ }

/* EXPORT */
module.exports = Spinner;
module.exports.default = Spinner;
Object.defineProperty(module.exports, "__esModule", { value: true });
export default Spinner;

@@ -1,18 +0,17 @@

"use strict";
/* IMPORT */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.writeLine = void 0;
const cli_width_1 = __importDefault(require("cli-width"));
const fixed_width_string_1 = __importDefault(require("fixed-width-string"));
const readline_1 = __importDefault(require("readline"));
import truncate from 'tiny-truncate';
/* MAIN */
const writeLine = (line) => {
readline_1.default.clearLine(process.stdout, 0);
readline_1.default.cursorTo(process.stdout, 0);
line = (0, fixed_width_string_1.default)(line, (0, cli_width_1.default)());
process.stdout.write(line);
line = truncate(line);
const process = globalThis.process;
if (process) {
process.stdout?.clearLine?.(0);
process.stdout?.cursorTo?.(0);
process.stdout?.write?.(line);
}
else {
console.log(line);
}
};
exports.writeLine = writeLine;
/* EXPORT */
export { writeLine };
{
"name": "tiny-spinner",
"repository": "github:fabiospampinato/tiny-spinner",
"description": "A simple, yet beautiful, CLI spinner.",
"version": "1.1.0",
"version": "2.0.0",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"clean": "rimraf dist",
"compile": "tsc --skipLibCheck && tstei",
"compile:watch": "tsc --skipLibCheck --watch",
"clean": "tsex clean",
"compile": "tsex compile",
"compile:watch": "tsex compile --watch",
"test": "node test/index.js",
"prepublishOnly": "npm run clean && npm run compile"
},
"bugs": {
"url": "https://github.com/fabiospampinato/tiny-spinner/issues"
},
"license": "MIT",
"author": {
"name": "Fabio Spampinato",
"email": "spampinabio@gmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/fabiospampinato/tiny-spinner.git"
},
"keywords": [

@@ -35,15 +26,11 @@ "cli",

"dependencies": {
"cli-width": "^3.0.0",
"fixed-width-string": "^2.0.0",
"kleur": "^4.1.4",
"stdin-blocker": "^1.0.0",
"tiny-cursor": "^1.0.0"
"stdin-blocker": "^2.0.0",
"tiny-colors": "^2.0.1",
"tiny-cursor": "^2.0.0",
"tiny-truncate": "^1.0.2"
},
"devDependencies": {
"@types/node": "^17.0.16",
"promise-resolve-timeout": "^1.2.1",
"rimraf": "^3.0.2",
"typescript": "^4.5.5",
"typescript-transform-export-interop": "^1.0.4"
"tsex": "^1.1.2",
"typescript": "^4.6.4"
}
}
/* IMPORT */
import color from 'kleur';
import Blocker from 'stdin-blocker';
import colors from 'tiny-colors';
import Cursor from 'tiny-cursor';

@@ -16,3 +16,3 @@ import {FRAMES, FRAMES_INTERVAL, SYMBOL_ERROR, SYMBOL_SUCCESS, SYMBOL_WARNING} from './constants';

private intervalId?: NodeJS.Timer;
private intervalId?: number;
private iteration = 0;

@@ -26,3 +26,3 @@ private message = '';

const frame = FRAMES[( this.iteration++ ) % FRAMES.length];
const line = `${color.cyan ( frame )} ${this.message}`;
const line = `${colors.cyan ( frame )} ${this.message}`;

@@ -54,3 +54,3 @@ writeLine ( line );

return this.stop ( `${color.yellow ( SYMBOL_WARNING )} ${message}` );
return this.stop ( `${colors.yellow ( SYMBOL_WARNING )} ${message}` );

@@ -61,3 +61,3 @@ };

return this.stop ( `${color.green ( SYMBOL_SUCCESS )} ${message}` );
return this.stop ( `${colors.green ( SYMBOL_SUCCESS )} ${message}` );

@@ -68,3 +68,3 @@ };

return this.stop ( `${color.red ( SYMBOL_ERROR )} ${message}` );
return this.stop ( `${colors.red ( SYMBOL_ERROR )} ${message}` );

@@ -71,0 +71,0 @@ };

/* IMPORT */
import width from 'cli-width';
import truncate from 'fixed-width-string';
import readline from 'readline';
import truncate from 'tiny-truncate';

@@ -12,9 +10,18 @@ /* MAIN */

readline.clearLine ( process.stdout, 0 );
readline.cursorTo ( process.stdout, 0 );
line = truncate ( line );
line = truncate ( line, width () );
const process = globalThis.process;
process.stdout.write ( line );
if ( process ) {
process.stdout?.clearLine?.( 0 );
process.stdout?.cursorTo?.( 0 );
process.stdout?.write?.( line );
} else {
console.log ( line );
}
};

@@ -21,0 +28,0 @@

/* IMPORT */
const color = require ( 'kleur' );
const delay = require ( 'promise-resolve-timeout' );
const {default: Spinner} = require ( '../dist' );
import {setTimeout as delay} from 'node:timers/promises';
import Spinner from '../dist/index.js';

@@ -8,0 +7,0 @@ /* MAIN */

{
"extends": "tsex/tsconfig.json",
"compilerOptions": {
"alwaysStrict": true,
"declaration": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"inlineSourceMap": false,
"jsx": "react",
"lib": ["dom", "esnext"],
"module": "commonjs",
"moduleResolution": "node",
"newLine": "LF",
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"outDir": "dist",
"pretty": true,
"resolveJsonModule": true,
"strictNullChecks": true,
"target": "es2020"
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
"noImplicitAny": false
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc