### Initialize and Start Spinner Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Demonstrates how to import and initialize a new spinner instance, then start it with a custom message and handle completion. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Run test').start() setTimeout(() => { spinner.success() }, 1000) ``` -------------------------------- ### Start Spinner Animation with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Illustrates how to start the spinner animation using the `start` method. It covers starting with default text, new text via string shorthand, and starting with an options object for text and color overrides. Also shows chained usage. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner() // Start with default text spinner.start() // Start with new text (string shorthand) spinner.start('Downloading packages...') // Start with options object spinner.start({ text: 'Installing dependencies', color: 'blue' }) // Chained usage createSpinner('Compiling source code').start() ``` -------------------------------- ### Complete Async/Await Example with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt A comprehensive example demonstrating proper error handling and spinner lifecycle management within asynchronous workflows using nanospinner. ```javascript import { createSpinner } from 'nanospinner' async function deployApplication() { const spinner = createSpinner('Starting deployment...').start() try { // Step 1: Build spinner.update({ text: 'Building application...', color: 'yellow' }) await runBuild() // Step 2: Test spinner.update({ text: 'Running tests...', color: 'cyan' }) const testResults = await runTests() if (testResults.warnings > 0) { spinner.warn(`Tests passed with ${testResults.warnings} warnings`) spinner.start('Continuing deployment...') } // Step 3: Deploy spinner.update({ text: 'Deploying to production...', color: 'magenta' }) await deploy() spinner.success('Deployment complete!') } catch (error) { spinner.error(`Deployment failed: ${error.message}`) process.exit(1) } } // Helper functions (mock implementations) const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)) const runBuild = () => sleep(2000) const runTests = () => sleep(1500).then(() => ({ warnings: 2 })) const deploy = () => sleep(3000) dependApplication() ``` -------------------------------- ### spinner.start Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Starts the spinner animation with optional text and color overrides. ```APIDOC ## spinner.start(options) ### Description Starts the spinner animation with optional text and color overrides. The spinner automatically loops through animation frames at the configured interval. Returns the spinner instance for method chaining. ### Method `spinner.start` ### Endpoint N/A (Method of a spinner object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string | object) - Optional - Either a string for new text or an object containing `text` and/or `color` overrides. - **text** (string) - Optional - New text to display with the spinner. - **color** (string) - Optional - Spinner color override. ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner() // Start with default text spinner.start() // Start with new text (string shorthand) spinner.start('Downloading packages...') // Start with options object spinner.start({ text: 'Installing dependencies', color: 'blue' }) // Chained usage createSpinner('Compiling source code').start() ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - The spinner instance, allowing for method chaining. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### Spinner Control Methods Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Covers the core control methods including start, stop, and manual animation spinning. ```javascript spinner.spin() spinner.start() spinner.start('Start') spinner.start({ text: 'Start', color: 'yellow' }) spinner.stop() spinner.stop('Done!') spinner.stop({ text: 'Done!', mark: ':O', color: 'magenta' }) ``` -------------------------------- ### Display Warning Indicator with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Explains how to stop the spinner and display a warning indicator using the `warn` method. Examples cover basic warning, warning with a message, and warning with custom options for text and mark. The indicator is '⚠' on Unicode terminals and '!!' on Windows, colored yellow. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Checking dependencies').start() setTimeout(() => { // Basic warning spinner.warn() // Warning with message spinner.warn('Found 3 outdated packages') // Warning with custom options spinner.warn({ text: 'Deprecated API detected', mark: '⚡' }) }, 1500) ``` -------------------------------- ### Display Info Indicator with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Details how to stop the spinner and display an informational indicator using the `info` method. It includes examples for basic info, info with a message, and info with custom options for text and mark. The indicator is 'ℹ' on Unicode terminals and 'i' on Windows, colored blue. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Analyzing project').start() setTimeout(() => { // Basic info spinner.info() // Info with message spinner.info('Found 156 source files') // Info with custom options spinner.info({ text: 'Using cached results', mark: '→' }) }, 1000) ``` -------------------------------- ### Display Error Indicator with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Demonstrates how to stop the spinner and display an error indicator using the `error` method. It includes examples for basic error, error with a custom message, and error with custom options for text and mark. The indicator is '✖' on Unicode terminals and '×' on Windows, colored red. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Connecting to database').start() async function connectDB() { try { await database.connect() spinner.success('Connected to database') } catch (err) { // Basic error spinner.error() // Error with custom message spinner.error(`Connection failed: ${err.message}`) // Error with custom options spinner.error({ text: 'Database unreachable', mark: '✗' }) } } ``` -------------------------------- ### Nano Spinner Initialization and Basic Usage Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Demonstrates how to import and use the createSpinner function to initialize and manage a spinner. ```APIDOC ## Nano Spinner Initialization and Basic Usage ### Description This section shows how to import the `createSpinner` function and use it to start and stop a spinner with a success message. ### Method Import and instantiate `createSpinner`. ### Endpoint N/A (Local module) ### Parameters N/A ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Run test').start() setTimeout(() => { spinner.success() }, 1000) ``` ### Response #### Success Response (200) N/A (This is a client-side operation) #### Response Example N/A ``` -------------------------------- ### Create Spinner Instance with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Demonstrates how to create a new spinner instance using the `createSpinner` factory function. It shows basic usage with default options and advanced usage with custom configurations for color, stream, frames, and interval. Supports CommonJS and ES Modules. ```javascript import { createSpinner } from 'nanospinner' // Basic spinner with default options const spinner = createSpinner('Loading data...') // Spinner with custom options const customSpinner = createSpinner('Processing files', { color: 'cyan', stream: process.stdout, frames: ['◐', '◓', '◑', '◒'], interval: 80 }) // Available color options: black, red, green, yellow, blue, magenta, cyan, white, gray ``` -------------------------------- ### Spinner Utility Methods Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Explains utility methods for clearing and resetting the spinner's output. ```APIDOC ## Spinner Utility Methods ### Description This section covers utility methods for managing the spinner's display, specifically for clearing its output and resetting it to its initial state. ### Methods - `.clear() - `.reset() ### Endpoint N/A (Local module methods) ### Parameters #### `.clear()` No parameters. #### `.reset()` No parameters. ### Request Example ```javascript // Clears the current spinner output from the terminal spinner.clear() // Resets the spinner to its initial frame and state spinner.reset() ``` ### Response #### Success Response (200) N/A (These are client-side operations) #### Response Example N/A ``` -------------------------------- ### Spinner Completion States Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Details on how to indicate different completion states (success, warning, error, info) for the spinner. ```APIDOC ## Spinner Completion States ### Description This section describes the methods used to stop the spinner and indicate a specific completion state with a corresponding mark and message. ### Methods - `.success(options?) - `.warn(options?) - `.error(options?) - `.info(options?) ### Endpoint N/A (Local module methods) ### Parameters #### `.success(options?)` - **text** (string) - Optional - The success message. - **mark** (string) - Optional - The success mark character (e.g., ':)' ). #### `.warn(options?)` - **text** (string) - Optional - The warning message. - **mark** (string) - Optional - The warning mark character (e.g., ':|'). #### `.error(options?)` - **text** (string) - Optional - The error message. - **mark** (string) - Optional - The error mark character (e.g., ':('). #### `.info(options?)` - **text** (string) - Optional - The info message. - **mark** (string) - Optional - The info mark character (e.g., 'i'). ### Request Example ```javascript spinner.success('Operation completed successfully!') spinner.warn('Configuration might be outdated.') spinner.error('Failed to process request.') spinner.info('Processing user data...') ``` ### Response #### Success Response (200) N/A (These are client-side operations) #### Response Example N/A ``` -------------------------------- ### Completion Status Methods Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Shows how to end the spinner with specific status indicators like success, warn, error, or info. ```javascript spinner.success({ text: 'Successful!', mark: ':)' }) spinner.warn({ text: 'Warning!', mark: ':|' }) spinner.error({ text: 'Error!', mark: ':(' }) spinner.info({ text: 'Info!', mark: 'i' }) ``` -------------------------------- ### Update and Reset Spinner Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Demonstrates how to dynamically update spinner properties, clear output, or reset the animation frame. ```javascript spinner.update({ text: 'Run test', color: 'white', interval: 100 }) spinner.clear() spinner.reset() ``` -------------------------------- ### createSpinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Factory function to create a new spinner instance with optional initial text and configuration options. ```APIDOC ## createSpinner(text, options) ### Description Creates a new spinner instance with optional initial text and configuration options. The function returns a chainable Spinner object that provides all animation and state management methods. ### Method `createSpinner` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **text** (string) - Optional - Initial text to display with the spinner. - **options** (object) - Optional - Configuration options for the spinner. - **color** (string) - Optional - Spinner color (picocolors supported colors like 'cyan', 'blue', etc.). - **stream** (WritableStream) - Optional - Output stream (default: `process.stderr`). - **frames** (string[]) - Optional - Custom animation frames array. - **interval** (number) - Optional - Frame interval in milliseconds (default: 50). ### Request Example ```javascript import { createSpinner } from 'nanospinner' // Basic spinner with default options const spinner = createSpinner('Loading data...') // Spinner with custom options const customSpinner = createSpinner('Processing files', { color: 'cyan', stream: process.stdout, frames: ['◐', '◓', '◑', '◒'], interval: 80 }) ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - A chainable spinner object with methods like `start`, `stop`, `success`, `error`, `warn`, `info`. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### Display Success Indicator with Nanospinner Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Shows how to stop the spinner and display a success indicator using the `success` method. It covers basic success, success with a custom message, and success with custom options including text and mark. The indicator is '✔' on Unicode terminals and '√' on Windows, colored green. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Running tests').start() // After async operation completes setTimeout(() => { // Basic success spinner.success() // Success with custom message spinner.success('All 42 tests passed!') // Success with custom options spinner.success({ text: 'Build complete', mark: '✓' }) }, 2000) ``` -------------------------------- ### spinner.success Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Stops the spinner and displays a success indicator. ```APIDOC ## spinner.success(options) ### Description Stops the spinner and displays a success indicator (✔ on Unicode terminals, √ on Windows). Automatically applies green color to the mark. Returns the spinner instance. ### Method `spinner.success` ### Endpoint N/A (Method of a spinner object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string | object) - Optional - Either a string for a custom success message or an object containing `text` and/or `mark` overrides. - **text** (string) - Optional - Custom message to display after the success mark. - **mark** (string) - Optional - Custom success mark character. ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Running tests').start() // After async operation completes setTimeout(() => { // Basic success spinner.success() // Success with custom message spinner.success('All 42 tests passed!') // Success with custom options spinner.success({ text: 'Build complete', mark: '✓' }) }, 2000) ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - The spinner instance, allowing for method chaining. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### spinner.warn Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Stops the spinner and displays a warning indicator. ```APIDOC ## spinner.warn(options) ### Description Stops the spinner and displays a warning indicator (⚠ on Unicode terminals, !! on Windows). Automatically applies yellow color to the mark. Returns the spinner instance. ### Method `spinner.warn` ### Endpoint N/A (Method of a spinner object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string | object) - Optional - Either a string for a custom warning message or an object containing `text` and/or `mark` overrides. - **text** (string) - Optional - Custom message to display after the warning mark. - **mark** (string) - Optional - Custom warning mark character. ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Checking dependencies').start() setTimeout(() => { // Basic warning spinner.warn() // Warning with message spinner.warn('Found 3 outdated packages') // Warning with custom options spinner.warn({ text: 'Deprecated API detected', mark: '⚡' }) }, 1500) ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - The spinner instance, allowing for method chaining. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### spinner.info Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Stops the spinner and displays an info indicator. ```APIDOC ## spinner.info(options) ### Description Stops the spinner and displays an info indicator (ℹ on Unicode terminals, i on Windows). Automatically applies blue color to the mark. Returns the spinner instance. ### Method `spinner.info` ### Endpoint N/A (Method of a spinner object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string | object) - Optional - Either a string for a custom info message or an object containing `text` and/or `mark` overrides. - **text** (string) - Optional - Custom message to display after the info mark. - **mark** (string) - Optional - Custom info mark character. ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Analyzing project').start() setTimeout(() => { // Basic info spinner.info() // Info with message spinner.info('Found 156 source files') // Info with custom options spinner.info({ text: 'Using cached results', mark: '→' }) }, 1000) ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - The spinner instance, allowing for method chaining. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### Spinner Animation Control Source: https://github.com/usmanyunusov/nanospinner/blob/master/README.md Covers methods for controlling the spinner's animation loop and updating its appearance. ```APIDOC ## Spinner Animation Control ### Description This section details methods for controlling the spinner's animation, including continuous spinning, starting, stopping, and updating its text and appearance. ### Methods - `.spin()` - `.start(options?) - `.stop(options?) - `.update(options?) ### Endpoint N/A (Local module methods) ### Parameters #### `.spin()` No parameters. #### `.start(options?)` - **text** (string) - Optional - The text to display next to the spinner. - **color** (string) - Optional - The color of the spinner and text (e.g., 'yellow'). #### `.stop(options?)` - **text** (string) - Optional - The text to display after stopping. - **mark** (string) - Optional - The character to replace the spinner with (e.g., ':O'). - **color** (string) - Optional - The color of the final text. #### `.update(options?)` - **text** (string) - Optional - The new text to display. - **color** (string) - Optional - The new color for the spinner and text. - **stream** (Stream) - Optional - The output stream (e.g., `process.stdout`). - **frames** (string[]) - Optional - An array of characters to use for the spinner animation. - **interval** (number) - Optional - The interval in milliseconds between frames. ### Request Example ```javascript // Continuous spinning setInterval(() => { spinner.spin() }, 25) // Starting with options spinner.start({ text: 'Loading...', color: 'blue' }) // Stopping with options spinner.stop({ text: 'Finished!', mark: '✔', color: 'green' }) // Updating spinner properties spinner.update({ text: 'Processing...', color: 'cyan', frames: ['-', '\\', '|', '/'], interval: 50 }) ``` ### Response #### Success Response (200) N/A (These are client-side operations) #### Response Example N/A ``` -------------------------------- ### spinner.error Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Stops the spinner and displays an error indicator. ```APIDOC ## spinner.error(options) ### Description Stops the spinner and displays an error indicator (✖ on Unicode terminals, × on Windows). Automatically applies red color to the mark. Returns the spinner instance. ### Method `spinner.error` ### Endpoint N/A (Method of a spinner object) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **options** (string | object) - Optional - Either a string for a custom error message or an object containing `text` and/or `mark` overrides. - **text** (string) - Optional - Custom message to display after the error mark. - **mark** (string) - Optional - Custom error mark character. ### Request Example ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Connecting to database').start() async function connectDB() { try { await database.connect() spinner.success('Connected to database') } catch (err) { // Basic error spinner.error() // Error with custom message spinner.error(`Connection failed: ${err.message}`) // Error with custom options spinner.error({ text: 'Database unreachable', mark: '✗' }) } } ``` ### Response #### Success Response (Spinner Object) - **spinner** (object) - The spinner instance, allowing for method chaining. #### Response Example ```json { "spinner": "[Spinner Object]" } ``` ``` -------------------------------- ### Dynamically Update Spinner Properties Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Dynamically updates the spinner's text, color, frames, or interval while it's running. Changes take effect on the next frame render. Returns the spinner instance. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Starting...').start() // Update text only (string shorthand) setTimeout(() => spinner.update('Step 1: Downloading...'), 1000) setTimeout(() => spinner.update('Step 2: Extracting...'), 2000) setTimeout(() => spinner.update('Step 3: Installing...'), 3000) // Update with full options setTimeout(() => { spinner.update({ text: 'Almost done...', color: 'green', frames: ['.', '..', '...'], interval: 200 }) }, 4000) setTimeout(() => spinner.success('Complete!'), 5000) ``` -------------------------------- ### Stop Spinner Animation with Options Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Stops the spinner animation and optionally displays final text, a mark, and a color. This is the base method for success(), error(), warn(), and info(). It returns the spinner instance. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Processing...').start() setTimeout(() => { // Stop without message (clears line) spinner.stop() // Stop with message spinner.stop('Done!') // Stop with full options spinner.stop({ text: 'Operation completed', mark: '●', color: 'magenta' }) }, 2000) ``` -------------------------------- ### Manually Render Spinner Frame Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Manually renders a single frame of the spinner animation and advances to the next frame. This is useful for custom animation loops or integration with other systems. Returns the spinner instance. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Manual animation') // Custom animation loop with different interval const intervalId = setInterval(() => { spinner.spin() }, 100) // Stop after 3 seconds setTimeout(() => { clearInterval(intervalId) spinner.success('Done with manual animation') }, 3000) ``` -------------------------------- ### Reset Spinner to Initial State Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Resets the spinner to its initial frame and clears any running timers. This method does not affect the spinner's configuration. Returns the spinner instance. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Running task').start() setTimeout(() => { spinner.reset() // Spinner is now at frame 0 and stopped // Start fresh spinner.start('Running new task') }, 2000) setTimeout(() => spinner.success(), 4000) ``` -------------------------------- ### Clear Spinner Output from Terminal Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Clears the spinner's output from the terminal without stopping the animation. This is useful for inserting other output while the spinner is running. Returns the spinner instance. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Processing items').start() function logProgress(item) { spinner.clear() console.log(`Processed: ${item}`) spinner.spin() } // Log progress while spinner continues setTimeout(() => logProgress('item-1'), 500) setTimeout(() => logProgress('item-2'), 1000) setTimeout(() => logProgress('item-3'), 1500) setTimeout(() => spinner.success('All items processed'), 2000) ``` -------------------------------- ### Check if Spinner is Active Source: https://context7.com/usmanyunusov/nanospinner/llms.txt Returns a boolean indicating whether the spinner is currently active. This is useful for conditional logic and cleanup operations. ```javascript import { createSpinner } from 'nanospinner' const spinner = createSpinner('Background task') console.log(spinner.isSpinning()) // false spinner.start() console.log(spinner.isSpinning()) // true spinner.success() console.log(spinner.isSpinning()) // false // Practical usage in cleanup process.on('exit', () => { if (spinner.isSpinning()) { spinner.stop() } }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.