How to use the mz/fs.createReadStream function in mz

To help you get started, we’ve selected a few mz 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 EpistasisLab / pennai / machine / machine.js View on Github external
console.log('pushing file' + file_path);
        if (file_path.match(/\.json$/)) {
            results = JSON.parse(fs.readFileSync(file_path, "utf-8"));
            var ret = {
                        uri: uri,
                        method: "PUT",
                        json: results,
                        gzip: true
                    };
        } else {
            // Create form data
            var formData = {
                files: []
            };
            // Add file
            formData.files.push(fs.createReadStream(file_path));
            var ret = {
                      uri: uri + "/files",
                      method: "PUT",
                      formData: formData,
                      gzip: true
                    };
        }
        filesP.push(rp(ret));
    };
github kissweb / kiss / index.js View on Github external
if (stats.mtime instanceof Date) res.lastModified = stats.mtime
  if (typeof stats.size === 'number') res.length = stats.size
  res.type = stats.type || path.extname(stats.pathname)
  res.etag = yield this._etag(stats)
  res.set('Cache-Control', this._cacheControl)

  // do we push dependencies on 304s?
  let fresh = req.fresh
  if (fresh) return res.status = 304

  if (req.method === 'HEAD') return

  assert('body' in stats || 'filename' in stats)
  res.body = 'body' in stats
    ? stats.body
    : fs.createReadStream(stats.filename)
}
github cnpm / npminstall / lib / download / npm.js View on Github external
} else {
          // rename error
          throw err;
        }
      }
    } else {
      // clean tmpFile
      await fs.unlink(tmpFile);
    }
    const stat = await fs.stat(tarballFile);
    debug('[%s@%s] saved %s %s => %s',
      pkg.name, pkg.version, bytes(stat.size), tarballUrl, tarballFile);
    options.totalTarballSize += stat.size;
  }

  const stream = fs.createReadStream(tarballFile);
  stream.tarballFile = tarballFile;
  return stream;
}
github fs-utils / cp / test / index.js View on Github external
it('should copy a stream', function () {
    var out = path.join(build, 'test2.js')
    return cp(fs.createReadStream(__filename), out).then(function (_out) {
      assert.equal(out, _out);
      return fs.stat(out)
    })
  })
github mozilla-b2g / fxos-device-service / src / fxos / readGeckoCommit.js View on Github external
async function readGeckoRevisionFromIni(iniFile) {
  let stream = fs.createReadStream(iniFile, {encoding: 'utf8'});
  let line = await findInStream(stream, matchSourceStamp);

  return matchSourceStamp(line).split('=')[1];
}
github koajs / file-server / index.js View on Github external
res.etag = file.etag
    res.lastModified = file.stats.mtime
    res.type = file.type
    if (cachecontrol) res.set('Cache-Control', cachecontrol)

    if (req.fresh) {
      res.status = 304
      return file
    }

    if (method === 'HEAD') return file

    if (file.compress && req.acceptsEncodings('gzip', 'identity') === 'gzip') {
      res.set('Content-Encoding', 'gzip')
      res.length = file.compress.stats.size
      res.body = fs.createReadStream(file.compress.path)
    } else {
      res.set('Content-Encoding', 'identity')
      res.length = file.stats.size
      res.body = fs.createReadStream(path)
    }

    return file
  }
github koajs / file-server / index.js View on Github external
yield function (done) {
      fs.createReadStream(path)
      .on('error', done)
      .pipe(zlib.createGzip())
      .on('error', done)
      .pipe(fs.createWriteStream(tmp))
      .on('error', done)
      .on('finish', done)
    }
github SynBioHub / synbiohub / scripts / sorted-n3-to-rdfxml.js View on Github external
return new Promise((resolve, reject) => {
    readStream = byline(fs.createReadStream(filename))

    readStream.on('data', (line) => {
      parseTriple(line.toString())
    })

    readStream.on('finish', () => {
      resolve()
    })
  })
}
github pnpm / pnpm / packages / package-requester / src / packageRequester.ts View on Github external
registry?: string,
    tarball: string,
  },
  pkgInStoreLocation: string,
  lockfileDir: string,
) {
  let currentIntegrity!: string
  try {
    currentIntegrity = (await fs.readFile(path.join(pkgInStoreLocation, TARBALL_INTEGRITY_FILENAME), 'utf8'))
  } catch (err) {
    return false
  }
  if (resolution.integrity && currentIntegrity !== resolution.integrity) return false

  const tarball = path.join(lockfileDir, resolution.tarball.slice(5))
  const tarballStream = fs.createReadStream(tarball)
  try {
    return Boolean(await ssri.checkStream(tarballStream, currentIntegrity))
  } catch (err) {
    return false
  }
}