1.2.0 • Published 2 months ago

nanospinner v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Nano Spinner

The simplest and tiniest terminal spinner for Node.js

import { createSpinner } from 'nanospinner'

const spinner = createSpinner('Run test').start()

setTimeout(() => {
  spinner.success()
}, 1000)
  • Only single dependency (picocolors).
  • It 45 times smaller than ora.
  • Support both CJS and ESM projects.
  • TypeScript type declarations included.

Motivation

With nanospinner we are trying to draw attention to the node_modules size problem and promote performance-first culture.

Benchmarks

The space in node_modules including sub-dependencies:

$ node ./test/size.js
Data from packagephobia.com
  ora           597 kB
+ nanospinner    13 kB

API

.spin()

Looping over spin method will animate a given spinner.

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

.start(options?)

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

spinner.start()
spinner.start({ text: 'Start', color: 'yellow' })

.stop(options?)

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

spinner.stop()
spinner.stop({ text: 'Done!', mark: ':O', color: 'magenta' })

.success(options?)

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({ text: 'Successful!', mark: ':)' })

.warn(options?)

Use warn call to stop the spinning animation and replace the spinning symbol with warn mark character to indicate warning completion.

spinner.warn()
spinner.warn({ text: 'Warning!', mark: ':|' })

.error(options?)

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

spinner.error()
spinner.error({ text: 'Error!', mark: ':(' })

.update(options?)

Use update call to dynamically change

spinner.update({
  text: 'Run test',
  color: 'white',
  stream: process.stdout,
  frames: ['.', 'o', '0', '@', '*'],
  interval: 100,
})

.clear()

Clears the spinner`s output

spinner.clear()

.reset()

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

spinner.reset()

Roadmap

  • Multi spinners
1.2.0

2 months ago

1.1.0

3 years ago

1.0.0

3 years ago

0.5.0

3 years ago

0.6.0

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.2.2

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago

0.0.0

3 years ago