{"id":23325155,"url":"https://github.com/mratanusarkar/nodejs-progressbar","last_synced_at":"2025-08-26T14:28:29.385Z","repository":{"id":42681096,"uuid":"473476490","full_name":"mratanusarkar/NodeJS-ProgressBar","owner":"mratanusarkar","description":"CLI Progress Bar implemented in NodeJS to track Time, ETA and Steps for any long running jobs in any loops in JS, NodeJS code","archived":false,"fork":false,"pushed_at":"2023-06-15T08:27:10.000Z","size":1417,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-03T17:51:36.732Z","etag":null,"topics":["alert","ascii","cli","console","javascript","loop","node","nodejs","notification","npm","npm-module","npm-package","progress-bar","progressbar","tool"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/progress-bar-cli","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mratanusarkar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T06:01:44.000Z","updated_at":"2023-12-21T17:09:01.000Z","dependencies_parsed_at":"2024-12-20T18:32:18.083Z","dependency_job_id":"54d067a0-cd32-49a4-93f6-3739355e4ea1","html_url":"https://github.com/mratanusarkar/NodeJS-ProgressBar","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mratanusarkar%2FNodeJS-ProgressBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mratanusarkar%2FNodeJS-ProgressBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mratanusarkar%2FNodeJS-ProgressBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mratanusarkar%2FNodeJS-ProgressBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mratanusarkar","download_url":"https://codeload.github.com/mratanusarkar/NodeJS-ProgressBar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233819581,"owners_count":18735302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alert","ascii","cli","console","javascript","loop","node","nodejs","notification","npm","npm-module","npm-package","progress-bar","progressbar","tool"],"created_at":"2024-12-20T18:29:41.345Z","updated_at":"2025-01-13T22:44:51.195Z","avatar_url":"https://github.com/mratanusarkar.png","language":"JavaScript","readme":"# NodeJS-ProgressBar\n[![NPM version](https://img.shields.io/npm/v/progress-bar-cli)](https://www.npmjs.com/package/progress-bar-cli)\n[![HitCount](https://hits.dwyl.com/mratanusarkar/NodeJS-ProgressBar.svg?style=flat)](http://hits.dwyl.com/mratanusarkar/NodeJS-ProgressBar)\n[![NPM downloads](https://img.shields.io/npm/dt/progress-bar-cli)](https://npmcharts.com/compare/progress-bar-cli?minimal=true)\n[![MIT License](https://img.shields.io/npm/l/progress-bar-cli)](LICENSE)\n\nCLI Progress Bar for NodeJS and JavaScript to track Time, ETA, and Steps for any long-running jobs in any loops in JS, NodeJS code\n\n[![NPM](https://nodei.co/npm/progress-bar-cli.png?mini=true)](https://nodei.co/npm/progress-bar-cli/)\n\nDid you ever encounter long-running processes or jobs running inside loops in javascript or nodejs? Did you ever encounter tasks where nodejs scripts are running in a server, making multiple api calls in long-running loops?\n\nIf you are tired of sitting and waiting for these processes and not knowing when this kind of job/loop will end. If you want to have metrics that will show you the current iteration number of the loop, eta of the job, the time elapsed, time to finish, estimated total time along with a cool cli progress bar, and even notify you with an alert sound when the job ends... then you are at the right place!\n\nHere is a running demo of the cli progress bar below: \u003cbr\u003e\n\n![running demo](./assets/style04-running-demo.gif)\n\n\n# Features\nThe function progressBar() can be applied to any determinate loop with finite and determined loop_len. \u003cbr\u003e\n\nIt has the following features:\n- you can change and modify the progress bar length\n- you can choose from the list of available cli ascii styles for the progress bar\n- you can resume the progress from the ith iteration (see examples)\n- you can set notifications for the progress bar to alert and notify you with a sound when the task is complete\n- you can choose to print out every iteration of the progress bar without clearing out the console screen\n- all-time information in the progress bar matrices is converted and printed in human-readable time\n\nAvailable matrices:\n  - iteration (current-step / total-step)\n  - number of iter/sec\n  - percentage completion\n  - time elapsed\n  - estimated time to completion\n  - estimated total time\n\n\nHere are some of the ASCII styles you can choose from:\n\n1. style=0\u003cbr\u003e\n![style 0](./assets/style00.png)\n\n2. style=1\u003cbr\u003e\n![style 1](./assets/style01.png)\n\n3. style=2\u003cbr\u003e\n![style 2](./assets/style02.png)\n\n4. style=3\u003cbr\u003e\n![style 3](./assets/style03.png)\n\n5. style=4\u003cbr\u003e\n![style 4](./assets/style04.png)\n\n\n# Installation\n```cmd\nnpm i progress-bar-cli\n```\n\n\n# Usage\n```node\nconst progressBar = require(\"progress-bar-cli\");\n\nlet loop_len = 1000;\nlet startTime = new Date();\nfor (i = 0; i \u003c loop_len; ++i) {\n    // call the progress bar at the start of the loop block\n    progressBar.progressBar(i, loop_len, startTime);\n    \n    /** START OF LONG-RUNNING JOB/PROCESS IN LOOP*/\n    //\n    // Insert your CODE Here!!\n    //\n    /** END OF LONG-RUNNING JOB/PROCESS IN LOOP*/\n}\n```\n\n\nIf the job gets halted in the middle or if the Job was multiple API calls in a loop, and maybe due to network issues the process got halted, \u003cbr\u003e\nyou can trace the last iteration of the running job from log files (if you are maintaining any), and resume the job from that ith iteration using the following code:\n\n```node\nconst progressBar = require(\"progress-bar-cli\");\n\nlet resumeFrom = 50;\nlet loop_len = 1000;\nlet startTime = new Date();\nfor (i = 0; i \u003c loop_len; ++i) {\n    // call progress bar at the start of the loop block\n    progressBar.progressBar(i, loop_len, startTime);\n    \n    // code to skip to the ith iteration and continue from there\n    if (i \u003c resumeFrom) {\n        console.log(\"\u003e skipping\", i);\n        continue;\n    }\n    \n    /** START OF LONG-RUNNING JOB/PROCESS IN LOOP*/\n    //\n    // Insert your CODE Here!!\n    //\n    /** END OF LONG-RUNNING JOB/PROCESS IN LOOP*/\n}\n```\n\n\n# Function Parameters\nParameter Name | Data Type | Default value | Description\n---------------|-----------|---------------|-------------\ncurrentStep | {Number} | *required | the current iteration number in the loop. eg: i, index, or count\ntotalSteps | {Number} | *required | total number of steps that the loop will run for.\nstartTime | {Date} | *required | pass the start time of the loop. It should be a Date object. eg: 'new Date()'\nclearScreenEvery | {Number} | 1 | console to be cleared off every ith iteration of this value.\nbarLength | {Number} | 50 | the length of the progress bar.\nstyle | {Number} | 4 | choose styles from 0 - 4.\nnotify | {Boolean} | false | set true for sound alert notification when complete. false to turn it off\n**function return** | {Number} | NA | currentStep++\n\n**Please Note**: * are the three required parameters for the function\n\n\n# Example\nBelow are some of the example codes where progressBar is used.\n\n1. using for loop:\n```node\nconst progressBar = require(\"progress-bar-cli\");\n\n// Main for testing the Progress Bar!\nlet loop_len = 100;\nlet counter = 0;\nlet resumeFrom = 0;\nlet startTime = new Date();\n\nconsole.time(\"total system time\");\nfor (i = 0; i \u003c loop_len; ++i) {\n    counter = progressBar.progressBar(counter, loop_len, startTime);\n\n    if (counter \u003c resumeFrom) {\n        console.log(\"\u003e skipping\", counter);\n        continue;\n    }\n\n    // do some time-consuming tasks in the loop\n    var waitTill = new Date(new Date().getTime() + 100);\n    while(waitTill \u003e new Date()){}\n}\nconsole.timeEnd(\"total system time\");\n\n```\n\n2. using a while loop\n```node\nconst progressBar = require(\"progress-bar-cli\");\n\n// Main for testing the Progress Bar!\nlet loop_len = 100;\nlet counter = 0;\nlet startTime = new Date();\n\nconsole.time(\"total system time\");\nwhile (counter \u003c loop_len) {\n    counter = progressBar.progressBar(counter, loop_len, startTime);\n\n    // do some time-consuming tasks in the loop\n    var waitTill = new Date(new Date().getTime() + 100);\n    while(waitTill \u003e new Date()){}\n}\nconsole.timeEnd(\"total system time\");\n\n```\n\n\n# Planned features for the upcoming version\n- [ ] TODO: add examples in the readme for forEach, for/in, for/of, do/while, and other types of loops in js and node \u003cbr\u003e\n- [ ] TODO: add support for async loops in js and node \u003cbr\u003e\n- [ ] TODO: add support for Indeterminate loops in js and node \u003cbr\u003e\n- [ ] TODO: add features to make the cli UI even better \u003cbr\u003e\n- [ ] TODO: add color and spinner if the running console/cli supports colorization \u003cbr\u003e\n- [ ] TODO: improve the sound alert and support for all OS without any package dependency \u003cbr\u003e\n- [ ] TODO: replace the sound alert system with something different and useful (based on community feedback!) \u003cbr\u003e\n      (as the sound feature is not that useful for systems running in server, VM, or pipeline-based applications)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmratanusarkar%2Fnodejs-progressbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmratanusarkar%2Fnodejs-progressbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmratanusarkar%2Fnodejs-progressbar/lists"}