Registry / elegant-spinner

elegant-spinner

JSON →
library3.0.0jsnpmunverified

elegant-spinner provides a simple, elegant set of ASCII frames designed for creating visual loading indicators in interactive command-line interface (CLI) applications. The current stable version is 3.0.0. This package itself does not handle the animation logic; rather, it supplies the individual spinner frames that an external utility (like `log-update` or `ora`) can iterate through to create an animated effect. Its release cadence is tied to Node.js compatibility updates and essential maintenance, rather than rapid feature development. A key differentiator is its minimalism, focusing solely on the spinner frames. However, for most use cases requiring a full-fledged animated spinner, the `ora` package is recommended as it bundles `elegant-spinner` and manages the animation loop automatically. It supports modern Node.js environments and is pure ESM since version 3.0.0, with TypeScript definitions available since version 2.0.0.

npm install elegant-spinner
INSTALL
IMPORT
SIG · ELEGANT-SPINNER
E
elegant-spinner
javascriptv3.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

elegantSpinner
import elegantSpinner from 'elegant-spinner';
const elegantSpinner = require('elegant-spinner');
Since v3.0.0, this package is pure ESM and must be imported using ES modules syntax. CommonJS `require()` will fail.
FrameIterator
import elegantSpinner from 'elegant-spinner'; const frame = elegantSpinner(); // frame() returns the next string frame
The default import is a factory function that returns an iterator for spinner frames. Call it to get the next frame string.

Demonstrates how to import the `elegantSpinner` function and use it with `log-update` to render a basic animated spinner in the terminal, manually updating frames every 50ms and showing a progress percentage.

import elegantSpinner from 'elegant-spinner'; import logUpdate from 'log-update'; const spinnerFrames = elegantSpinner(); let counter = 0; const interval = setInterval(() => { const currentFrame = spinnerFrames(); logUpdate(`Loading ${currentFrame} ${counter++}%`); if (counter > 100) { clearInterval(interval); logUpdate.done(); console.log('Loading complete!'); } }, 50);
Debug
Known issues
breakingVersion 3.0.0 and above is pure ESM (ECMAScript Modules). CommonJS `require()` statements are no longer supported and will result in an error.
fix
Migrate your project to use ES modules (`import`/`export`) or use an older version of the package if CommonJS is strictly required.
affects: >=3.0.0
breakingVersion 3.0.0 requires Node.js 12.20.0, 14.13.1, or >=16.0.0. Older Node.js versions are not supported.
fix
Upgrade your Node.js runtime to a compatible version.
affects: >=3.0.0
gotchaThis package only provides the spinner frames. It does not handle the animation logic (e.g., setting intervals, clearing output). For a complete, animated spinner solution, the `ora` package is generally recommended as it wraps `elegant-spinner` and handles animation automatically.
fix
For full animation, consider using `ora`. If sticking with `elegant-spinner`, you'll need to manually implement the animation loop using tools like `log-update` and `setInterval`.
affects: >=1.0.0
breakingVersion 2.0.0 required Node.js 8 or higher. Prior versions supported older Node.js environments.
fix
Ensure your Node.js version meets the requirement for the specific `elegant-spinner` version you are using. For versions 2.x, Node.js 8+ is needed.
affects: >=2.0.0 <3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to import `elegant-spinner` using CommonJS `require()` syntax in a Node.js environment with version 3.0.0 or later.
fix
Change your import statement from `const elegantSpinner = require('elegant-spinner');` to `import elegantSpinner from 'elegant-spinner';` and ensure your project is configured for ES modules (e.g., `"type": "module"` in package.json).
Upgrade
Version history
3.0.0latest on npm
Audit
Dependencies
log-updaterequiredCommonly used with elegant-spinner to render animated output by overwriting the terminal line.
Agent activity
2 hits · last 30 days
node
2
Resources