nanospinner
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

Nano Spinner

Simple and tiny multi spinner library for Node.js

  • It takes 18 times less space in node_modules than ora.
  • It is 6 times faster than mico-spinner.
import { createSpinner } from 'nanospinner'

let spinner = createSpinner('Run test')

spinner.start()
setTimeout(() => {
  spinner.success()
}, 1000)

Benchmarks

The space in node_modules including sub-dependencies:

$ ./test/size.js
Data from packagephobia.com
ora           597 kB
mico-spinner   28 kB
nanospinner    22 kB

Library loading time:

$ ./test/loading.js
mico-spinner  13.014 ms
nanospinner    1.930 ms

API

spin()

Looping over spin method will animate a given spinner.

setInterval(() => {
  spinner.spin()
}, 25)
start()

In order to start the spinner call start. This will perform drawing the spinning animation

spinner.start()
stop()

In order to stop the spinner call stop. This will finish drawing the spinning animation and return to new line.

spinner.stop()
spinner.stop('Done!')
success()

Use success call to stop the spinning animation and replace the spinning symbol with check mark character to indicate successful completion.

spinner.success()
spinner.success('Successful!')
error()

Use error call to stop the spinning animation and replace the spinning symbol with cross character to indicate error completion.

spinner.error()
spinner.error('Error!')
reset()

In order to reset the spinner to its initial frame do:

spinner.reset()

Package Sidebar

Install

npm i nanospinner@0.1.0

Version

0.1.0

License

MIT

Unpacked Size

10.1 kB

Total Files

13

Last publish

Collaborators

  • usmanyunusov