Charm is a module used to write colors and cursor positions to a stream.

Let's build a simple progress indicator with charm.

  npm install charm

Simple charm bar

Using setTimeout to write a charm bar. Because charm bar writes using the stream interface, using a blocking while loop will not write.

HTTP charm bar

Download the latest release of node and tick the charm bar on each chunk. Because req.on('data'... makes many trips around the event loop, charm.write will actually write to the stream it's piped to. In this case process.stdout.

HTTP Disco Charm Bar

Same as the HTTP charm bar, but set the foreground color disco style!!

There you go, a simple way to write progress indicators in node.