Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/roccomuso/pv
Unix Pipe Viewer (pv) utility in Node.js
https://github.com/roccomuso/pv
js nodejs pipe pv stream tool unix utility viewer
Last synced: 14 days ago
JSON representation
Unix Pipe Viewer (pv) utility in Node.js
- Host: GitHub
- URL: https://github.com/roccomuso/pv
- Owner: roccomuso
- Created: 2017-10-04T14:40:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-05-03T20:09:48.000Z (over 2 years ago)
- Last Synced: 2025-01-05T21:04:46.087Z (16 days ago)
- Topics: js, nodejs, pipe, pv, stream, tool, unix, utility, viewer
- Language: JavaScript
- Size: 5.86 KB
- Stars: 23
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# pv
[![NPM Version](https://img.shields.io/npm/v/pv.svg)](https://www.npmjs.com/package/pv)
[![Dependency Status](https://david-dm.org/roccomuso/pv.png)](https://david-dm.org/roccomuso/pv)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)Unix Pipe Viewer (pv) utility in Node.js
> Pipe viewer is a terminal-based tool for monitoring the progress of data through a pipeline. It can be inserted into any normal pipeline between two processes to give a visual indication of how quickly data is passing through, how long it has taken, how near to completion it is, and an estimate of how long it will be until completion.
## Install
$ npm install -g pv
## Example usage
$ cat /dev/urandom | pv --size 100MB > /dev/null
Example output:
45.02% | 5 ETA | 42.94MB Transferred | 9.54MB/s
Stats are updated every second.
## Available CLI options
- `-s, --size `: Assume the total amount of data to be transferred is SIZE. You can provide a size in bytes or using units (`b, kb, mb, gb, tb`).
- `-N, --name `: Prefix the output information with NAME.## Programmatic usage
```javascript
const PV = require('pv')
const readline = require('readline')const pv = PV({
size: /* ... */,
name: /* ... */,
time: /* Sets how often progress events are emitted in ms. If omitted then the default is to do so every time a chunk is received. */
})pv.on('info', function(info){
readline.clearLine(process.stderr, 0)
readline.cursorTo(process.stderr, 0, null)
let {speed, transferred} = info
process.stderr.write(`Speed: ${speed} - Processed: ${transferred}`)
/*
{
name: 'test',
percentage: 9.05,
transferred: 949624,
eta: 42,
speed: 949624
}
*/
})process.stdin.pipe(pv).pipe(process.stdout)
```## Author
Rocco Musolino ([@roccomuso](https://twitter.com/roccomuso))
## License
MIT