kevva / decompress

Extracting archives made easy
MIT License
415 stars 52 forks source link

Extraction events #35

Open mbrio opened 8 years ago

mbrio commented 8 years ago

A nice addition to this package would be emitting events such as progress and entry so that implementers can see how far along they are with their decompression and to know what the currently decompressing or decompressed file is.

const zip = new Decompress()
  .src(src)
  .dest(dest)
  .use(Decompress.zip())
  .on('progress', pe => {
    if (pe.lengthComputable) {
      const percent = Math.round(pe.decompressed / pe.total * 100);
      console.log(`${percent}% complete`);
    }
  })
  .on('entry', entry => {
    console.log(`Currently decompressing ${entry.fileName}.`);
  })
  .run();

The progress event data I modeled after the Web API standard: https://developer.mozilla.org/en-US/docs/Web/API/ProgressEvent and modified loaded to decompressed.

The entry event data I modeled after information found in the zip specification on wikipedia.

alandoyle95 commented 7 years ago

+1 really want this

lefuturiste commented 5 years ago

+1

yykoypj commented 10 months ago

+1