From f60e392520f63d7fbd0518279e669eed041edd07 Mon Sep 17 00:00:00 2001 From: fraxken Date: Tue, 1 Jul 2025 19:18:06 +0200 Subject: [PATCH] refactor!: rename interface starting with I Maj --- README.md | 8 ++++---- src/Spinner.class.ts | 8 ++++---- src/computeWithSpinner.ts | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1bf5428..b0eaf6e 100644 --- a/README.md +++ b/README.md @@ -77,13 +77,13 @@ spinner.succeed("All done !"); ## API -
constructor(options?: ISpinnerOptions) +
constructor(options?: SpinnerOptions)
Create a new Spinner. The **options** payload is described by the following TypeScript interface: ```ts -export interface ISpinnerOptions { +export interface SpinnerOptions { /** * Spinner name (from cli-spinners lib) * @@ -114,14 +114,14 @@ new Spinner({ name: "dots2" });
-
start(text?: string, options?: IStartOptions): Spinner +
start(text?: string, options?: StartOptions): Spinner Start the spinner and optionaly write the text passed as first parameter. The **options** payload is described by the following TypeScript interface: ```ts -export interface IStartOptions { +export interface StartOptions { withPrefix?: string; } ``` diff --git a/src/Spinner.class.ts b/src/Spinner.class.ts index dbc1ea8..318ee4e 100644 --- a/src/Spinner.class.ts +++ b/src/Spinner.class.ts @@ -27,7 +27,7 @@ const kLogSymbols = process.platform !== "win32" || process.env.CI || process.en { success: styleText("green", "✔"), error: styleText("red", "✖") } : { success: styleText("green", "√"), error: styleText("red", "×") }; -export interface ISpinnerOptions { +export interface SpinnerOptions { /** * Spinner name (from cli-spinners lib) * @@ -48,7 +48,7 @@ export interface ISpinnerOptions { verbose?: boolean; } -export interface IStartOptions { +export interface StartOptions { withPrefix?: string; } @@ -71,7 +71,7 @@ export class Spinner extends EventEmitter { #spinnerPos = 0; #startTime: number; - constructor(options: ISpinnerOptions = {}) { + constructor(options: SpinnerOptions = {}) { super(); this.#verbose = options.verbose ?? true; if (!this.#verbose) { @@ -169,7 +169,7 @@ export class Spinner extends EventEmitter { readline.moveCursor(this.stream, -(stringLength(line)), moveCursorPos); } - start(text?: string, options: IStartOptions = {}) { + start(text?: string, options: StartOptions = {}) { this.#started = true; this.text = text; if (typeof options.withPrefix === "string") { diff --git a/src/computeWithSpinner.ts b/src/computeWithSpinner.ts index 4751025..8d6080a 100644 --- a/src/computeWithSpinner.ts +++ b/src/computeWithSpinner.ts @@ -1,28 +1,28 @@ // Import Internal Dependencies import { Spinner, - type ISpinnerOptions + type SpinnerOptions } from "./Spinner.class.js"; // CONSTANTS // eslint-disable-next-line func-style const kDefaultSafeLogger = () => undefined; -export interface IComputeSpinnerOptions { +export interface ComputeSpinnerOptions { text: string; - spinner?: Omit; + spinner?: Omit; withPrefix?: string; } -export interface ISpinnerLoggerOptions { +export interface SpinnerLoggerOptions { success?: (elapsedTime: number) => string; fail?: (error: Error) => string; } export async function computeWithSpinner( asynchronousOp: (spinner: Spinner) => Promise, - options: IComputeSpinnerOptions, - logs: ISpinnerLoggerOptions = {} + options: ComputeSpinnerOptions, + logs: SpinnerLoggerOptions = {} ): Promise { const { success = kDefaultSafeLogger, fail = kDefaultSafeLogger } = logs; const spinner = new Spinner(options.spinner)