How to use progress-stream - 5 common examples

To help you get started, we’ve selected a few progress-stream examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jakoblo / ufo / src / js / filesystem / write / child-worker / fs-write-worker-copy.js View on Github external
transform: (read: ReadStream, write: WriteStream) => {
      // Insert Progress report in ncp stream
      // For every file in ncp

      var id = progressPerFileStack.length;
      progressPerFileStack[id] = 0;
      var str = progress({
        time: 100
      }).on("progress", progress => {
        progressPerFileStack[id] = progress.transferred;
        calcProgress();
      });
      read.pipe(str).pipe(write);
    }
  };
github itchio / itch / src / main / broth / unzip.ts View on Github external
const extractEntry = async (
    entry: yauzl.Entry,
    err: Error,
    src: NodeJS.ReadableStream
  ) => {
    if (err) {
      throw err;
    }

    const entryPath = join(destination, entry.fileName);

    await sf.mkdirp(dirname(entryPath));
    const dst = createWriteStream(entryPath);
    const progressStream = progress({
      length: entry.uncompressedSize,
      time: 100,
    });
    let progressFactor = entry.compressedSize / zipfile.fileSize;
    progressStream.on("progress", info => {
      opts.onProgress({
        progress: progressOffset + (info.percentage / 100) * progressFactor,
      });
    });
    progressStream.pipe(dst);
    src.pipe(progressStream);
    await sf.promised(dst);
    progressOffset += progressFactor;
    await sf.chmod(entryPath, 0o755);

    const fileBuffer = await sf.readFile(entryPath, { encoding: null });
github itchio / itch / src / main / net / download.ts View on Github external
sink: () => {
          progressStream = progress({ length: totalSize, time: 500 });
          progressStream.on("progress", info => {
            onProgress({
              progress: info.percentage / 100,
              eta: info.eta,
              bps: info.speed,
              doneBytes: (info.percentage / 100) * totalSize,
              totalBytes: totalSize,
            });
            logger.info(
              `${info.percentage.toFixed(1)}% done, eta ${info.eta.toFixed(
                1
              )}s @ ${fileSize(info.speed)}/s`
            );
          });
          progressStream.pipe(fileSink);
          return progressStream;
github jakoblo / ufo / src / js / filesystem / write / child-worker / fs-write-worker.js View on Github external
transform: (read, write) => {
        var str = progress({
          length: fs.statSync(read.path).size,
          time: 700
        });
        str.on('progress', (progress) => {
          process.send({
            type: t.FS_WRITE_PROGRESS,
            payload: {
              id: id,
              file: {
                source: read.path,
                destination: write.path,
                progress: progress}
            }
          })
        })
        read.pipe(str).pipe(write)
github sozialhelden / accessibility-cloud / both / api / sources / server / stream-chain / stream-types / generic.js View on Github external
constructor({ stream, onProgress }) {
    check(stream, Stream);
    this.stream = stream;

    if (onProgress) {
      const options = {
        time: 1000,
        speed: 1000,
      };
      const progressStream = createProgressStream(options, onProgress);
      this.stream = this.stream.pipe(progressStream);
    }
  }

progress-stream

Read the progress of a stream

BSD-2-Clause
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis

Popular progress-stream functions