Giter VIP home page Giter VIP logo

pv's Introduction

pv

NPM Version Dependency Status JavaScript Style Guide Patreon donate button

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 <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 <name>: Prefix the output information with NAME.

Programmatic usage

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)

License

MIT

pv's People

Contributors

roccomuso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

artskydj

pv's Issues

error when launching pv

Hello, I have install pv through nodejs but I have the following error when I try to use it

/usr/local/lib/node_modules/pv/bin/pv.js:28 stderr(${name} ${percentage} | ${eta} | ${transferred} | ${speed}) ^ SyntaxError: Unexpected token ILLEGAL at Module._compile (module.js:439:25) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3
I don't really understand

thx

stderr output, line get replaced

Multiple write on the stderr. The latter replace the first (get a reference to the line to use).

cat /dev/urandom | node bin/pv.js --size 100MB -N test1 | node bin/pv.js --size 100MB -N prova > /dev/null

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.