From 08f0769e39bbdf7d94236019f94f2c87653ccea2 Mon Sep 17 00:00:00 2001 From: fredgan Date: Mon, 26 Oct 2020 21:43:28 +0800 Subject: [PATCH] add updateColor.js at examples --- examples/updateColors.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/updateColors.js diff --git a/examples/updateColors.js b/examples/updateColors.js new file mode 100644 index 0000000..bc91c6d --- /dev/null +++ b/examples/updateColors.js @@ -0,0 +1,18 @@ +var ProgressBar = require('../'); + +var green = '\u001b[42m \u001b[0m'; +var red = '\u001b[41m \u001b[0m'; + +bar = new ProgressBar(':current/:total :bar :percent :elapseds', { + total: 100, + complete: green, + incomplete: red, +}); + +var id = setInterval(function (){ + bar.tick(); + if (bar.complete) { + clearInterval(id); + } +}, 100); +