Skip to content

Commit

Permalink
Merge pull request #7 from mratanusarkar/bugfix/cleanup
Browse files Browse the repository at this point in the history
cleanup after publish
  • Loading branch information
mratanusarkar authored Mar 27, 2022
2 parents 5fa7514 + b6d65bf commit 1677e9a
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 13 deletions.
101 changes: 101 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
coverage/

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
build/

# Dependency directories
*node_modules/
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TypeScript output
dist
out

# Azure Functions artifacts
bin
obj
appsettings.json
local.settings.json

# VS Code
.vscode
.vscode-test
106 changes: 106 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# github assets and repo files
assets/
index.js
.gitignore

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
coverage/

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
build/

# Dependency directories
*node_modules/
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TypeScript output
dist
out

# Azure Functions artifacts
bin
obj
appsettings.json
local.settings.json

# VS Code
.vscode
.vscode-test
62 changes: 49 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,29 @@ If you want to have a metrics that will show you the current iteration number of
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!

Here is a running demo of the cli progress bar below: <br>

![running demo](./assets/style04-running-demo.gif)


# Features
The function progressBar() can be applied to any deterministic loop with finite and determined loop_len. <br>
It has the following parameters and features:
- **currentStep**: the current iteration number in the loop. eg: i, index or count
- **totalSteps**: total number of steps that the loop will run for
- **startTime**: pass the start time of the loop. It should be a Date object. eg: 'new Date()'
- **clearScreenEvery**: console to be cleared off every ith itheration of this value. default: 1
- **barLength**: the length of the progress bar. default: 50
- **style**: choose styles from 0 - 4
- **notify**: set true for sound alert notofocation when complete. false to turn it off

It has the following features:
- you can change and modify the progress bar length
- you can choose from the list of available cli ascii styles for the progress bar
- you can resume the progress from the ith iteration (see examples)
- you can set notify for the progress bar to alert and notify you with sound when the task is complete
- you can choose to print out every iteration of the progress bar without clearing out the console screen
- all time information in the progress bar matrices are converted and printed in human readable time

Available matrices:
- iteration (current-step / total-step)
- number of iter / sec
- percentage completion
- time elapsed
- estimated time to completion
- estimated total time


Here are some of the ascii styles you can choose from:

Expand All @@ -42,9 +53,15 @@ Here are some of the ascii styles you can choose from:
![style 4](./assets/style04.png)


# Installation
```cmd
npm i progress-bar-cli
```


# Usage
```node
const progressBar = require("./progress-bar");
const progressBar = require("progress-bar-cli");

let loop_len = 1000;
let startTime = new Date();
Expand All @@ -65,7 +82,7 @@ If the job get's haulted in the middle or if the Job was multiple API calls in a
you 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:

```node
const progressBar = require("./progress-bar");
const progressBar = require("progress-bar-cli");

let resumeFrom = 50;
let loop_len = 1000;
Expand All @@ -89,12 +106,27 @@ for (i = 0; i < loop_len; ++i) {
```


# Function Parameters
Parameter Name | Data Type | default value | description
---------------|-----------|---------------|-------------
currentStep | {Number} | *required | the current iteration number in the loop. eg: i, index or count
totalSteps | {Number} | *required | total number of steps that the loop will run for.
startTime | {Date} | *required | pass the start time of the loop. It should be a Date object. eg: 'new Date()'
clearScreenEvery | {Number} | 1 | console to be cleared off every ith iteration of this value.
barLength | {Number} | 50 | the length of the progress bar.
style | {Number} | 4 | choose styles from 0 - 4.
notify | {Boolean} | true | set true for sound alert notification when complete. false to turn it off
**function return** | {Number} | NA | currentStep++

**Please Note**: * are the three required parameters for the function


# Example
Below are some of the example codes where progressBar is used.

1. using for loop:
```node
const progressBar = require("./progress-bar");
const progressBar = require("progress-bar-cli");

// Main for testing the Progress Bar!
let loop_len = 100;
Expand All @@ -121,7 +153,7 @@ console.timeEnd("total system time");

2. using while loop
```node
const progressBar = require("./progress-bar");
const progressBar = require("progress-bar-cli");

// Main for testing the Progress Bar!
let loop_len = 100;
Expand All @@ -140,6 +172,10 @@ console.timeEnd("total system time");

```

TODO: add examples for forEach, for/in, for/of, do/while and other types of loops in js and node <br>

# Planned features for upcoming version
TODO: add examples in readme for forEach, for/in, for/of, do/while and other types of loops in js and node <br>
TODO: add support for async loops in js and node
TODO: add support for macOS
TODO: make the cli ui even better

0 comments on commit 1677e9a

Please sign in to comment.