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

ora

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ora - npm Package Compare versions

Comparing version 6.2.0 to 6.3.0

21

index.d.ts

@@ -21,2 +21,4 @@ import {SpinnerName} from 'cli-spinners';

export type SuffixTextGenerator = () => string;
export interface Options {

@@ -34,2 +36,7 @@ /**

/**
Text or a function that returns text to display after the spinner text. No suffix text will be displayed if set to an empty string.
*/
readonly suffixText?: string | SuffixTextGenerator;
/**
Name of one of the provided spinners. See [`example.js`](https://github.com/BendingBender/ora/blob/main/example.js) in this repo if you want to test out different spinners. On Windows, it will always use the line spinner as the Windows command-line doesn't have proper Unicode support.

@@ -135,2 +142,9 @@

readonly prefixText?: string | PrefixTextGenerator;
/**
Text or a function that returns text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
Default: Current `suffixText`.
*/
readonly suffixText?: string | SuffixTextGenerator;
}

@@ -168,2 +182,9 @@

/**
Change the text or function that returns text after the spinner text.
No suffix text will be displayed if set to an empty string.
*/
suffixText: string;
/**
Change the spinner color.

@@ -170,0 +191,0 @@ */

45

index.js

@@ -27,2 +27,3 @@ import process from 'node:process';

#prefixText;
#suffixText;

@@ -61,2 +62,3 @@ color;

this.prefixText = this.#options.prefixText;
this.suffixText = this.#options.suffixText;
this.indent = this.#options.indent;

@@ -152,2 +154,11 @@

get suffixText() {
return this.#suffixText;
}
set suffixText(value) {
this.#suffixText = value || '';
this.updateLineCount();
}
get isSpinning() {

@@ -170,8 +181,22 @@ return this.#id !== undefined;

getFullSuffixText(suffixText = this.#suffixText, prefix = ' ') {
if (typeof suffixText === 'string' && suffixText !== '') {
return prefix + suffixText;
}
if (typeof suffixText === 'function') {
return prefix + suffixText();
}
return '';
}
updateLineCount() {
const columns = this.#stream.columns || 80;
const fullPrefixText = this.getFullPrefixText(this.#prefixText, '-');
const fullSuffixText = this.getFullSuffixText(this.#suffixText, '-');
const fullText = ' '.repeat(this.#indent) + fullPrefixText + '--' + this.#text + '--' + fullSuffixText;
this.#lineCount = 0;
for (const line of stripAnsi(' '.repeat(this.#indent) + fullPrefixText + '--' + this.#text).split('\n')) {
for (const line of stripAnsi(fullText).split('\n')) {
this.#lineCount += Math.max(1, Math.ceil(wcwidth(line) / columns));

@@ -216,4 +241,5 @@ }

const fullText = typeof this.text === 'string' ? ' ' + this.text : '';
const fullSuffixText = (typeof this.#suffixText === 'string' && this.#suffixText !== '') ? ' ' + this.#suffixText : '';
return fullPrefixText + frame + fullText;
return fullPrefixText + frame + fullText + fullSuffixText;
}

@@ -336,8 +362,17 @@

const prefixText = options.prefixText || this.#prefixText;
const text = options.text || this.text;
const prefixText = options.prefixText ?? this.#prefixText;
const fullPrefixText = this.getFullPrefixText(prefixText, ' ');
const symbolText = options.symbol ?? ' ';
const text = options.text ?? this.text;
const fullText = (typeof text === 'string') ? ' ' + text : '';
const suffixText = options.suffixText ?? this.#suffixText;
const fullSuffixText = this.getFullSuffixText(suffixText, ' ');
const textToWrite = fullPrefixText + symbolText + fullText + fullSuffixText + '\n';
this.stop();
this.#stream.write(`${this.getFullPrefixText(prefixText, ' ')}${options.symbol || ' '}${fullText}\n`);
this.#stream.write(textToWrite);

@@ -344,0 +379,0 @@ return this;

2

package.json
{
"name": "ora",
"version": "6.2.0",
"version": "6.3.0",
"description": "Elegant terminal spinner",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -53,2 +53,8 @@ # ora

##### suffixText
Type: `string | () => string`
Text or a function that returns text to display after the spinner text. No suffix text will be displayed if set to an empty string.
##### spinner

@@ -146,2 +152,8 @@

#### .suffixText <sup>get/set</sup>
Change the text after the spinner text.
No suffix text will be displayed if set to an empty string.
#### .color <sup>get/set</sup>

@@ -213,3 +225,3 @@

Text to be persisted after the symbol
Text to be persisted after the symbol.

@@ -223,2 +235,9 @@ ###### prefixText

###### suffixText
Type: `string`\
Default: Current `suffixText`
Text to be persisted after the text after the symbol. No suffix text will be displayed if set to an empty string.
<img src="screenshot-2.gif" width="480">

@@ -225,0 +244,0 @@

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