How to use minipass-collect - 1 common examples

To help you get started, we’ve selected a few minipass-collect 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 npm / make-fetch-happen / cache.js View on Github external
// old body to bring in the data.
    const newBody = new MinipassPipeline(new MinipassFlush({
      flush () {
        return cacheWritePromise
      }
    }))

    let cacheWriteResolve, cacheWriteReject
    const cacheWritePromise = new Promise((resolve, reject) => {
      cacheWriteResolve = resolve
      cacheWriteReject = reject
    })
    const cachePath = this._path

    if (fitInMemory) {
      const collecter = new MinipassCollect.PassThrough()
      collecter.on('collect', data => {
        cacache.put(
          cachePath,
          ckey,
          data,
          cacheOpts
        ).then(cacheWriteResolve, cacheWriteReject)
      })
      newBody.unshift(collecter)
    } else {
      const tee = new Minipass()
      const cacheStream = cacache.put.stream(
        cachePath,
        ckey,
        cacheOpts
      )

minipass-collect

A Minipass stream that collects all the data into a single chunk

ISC
Latest version published 11 months ago

Package Health Score

68 / 100
Full package analysis

Popular minipass-collect functions