How to use the lazystream.Readable function in lazystream

To help you get started, we’ve selected a few lazystream 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 dbankier / TiShadow / cli / support / bundle.js View on Github external
out.on("close", callback);
  // Use zlib compression 1 (fastest) to overcome a bug currently in Archiver on Macs
  zip = archiver('zip', {zlib: {level: 1}});
  zip.on('error', function(err) {
    throw err;
  });
  zip.pipe(out);

  for(var i = 0, ln = files.length; i < ln; i++) {
    var file = files[i],
        filename = config.tishadow_src + '/' + file,
        stream;

    // Lazy load streams, to counteract 'too many files' error on Node
    // Lazystream only creates the actual ReadStream when a read command is received
    stream = new lazystream.Readable(function (options) {
      return fs.createReadStream(this.filename);
    });
    stream.filename = filename;

    zip.append(stream, {name : files[i]});
  }

  zip.finalize();
};
github Fitbit / fitbit-sdk-toolchain / src / index.ts View on Github external
function lazyObjectReadable(fn: () => Readable) {
  const lazyStream = new lazystream.Readable(
    () => {
      try {
        return fn();
      } catch (ex) {
        lazyStream.emit('error', ex);
        return emptyReadable();
      }
    },
    { objectMode: true },
  );
  return lazyStream;
}
github jooby-project / jooby / jooby-assets-svg-sprites / src / main / resources / dr-svg-sprites / node_modules / vinyl-fs / lib / src / getContents / streamFile.js View on Github external
function streamFile(file, opt, cb) {
  if (typeof opt === 'function') {
    cb = opt;
    opt = {};
  }

  var filePath = file.path;

  file.contents = new lazystream.Readable(function() {
    return fs.createReadStream(filePath);
  });

  if (opt.stripBOM) {
    file.contents = file.contents.pipe(stripBom());
  }

  cb(null, file);
}
github gulpjs / vinyl-fs / lib / src / read-contents / read-stream.js View on Github external
function streamFile(file, optResolver, onRead) {
  if (typeof optResolver === 'function') {
    onRead = optResolver;
    optResolver = createResolver();
  }

  var filePath = file.path;

  var removeBOM = optResolver.resolve('removeBOM', file);

  file.contents = new lazystream.Readable(function() {
    var contents = fs.createReadStream(filePath);

    if (removeBOM) {
      return contents.pipe(removeBomStream());
    }

    return contents;
  });

  onRead();
}
github charlieschwabacher / gestalt / node_modules / vinyl-fs / lib / src / getContents / streamFile.js View on Github external
function streamFile(file, opt, cb) {
  if (typeof opt === 'function') {
    cb = opt;
    opt = {};
  }

  var filePath = file.path;

  file.contents = new lazystream.Readable(function() {
    return fs.createReadStream(filePath);
  });

  if (opt.stripBOM) {
    file.contents = file.contents.pipe(stripBom());
  }

  cb(null, file);
}
github nwjs / grunt-nw-builder / tasks / lib / compress.js View on Github external
files.forEach(function(srcFile) {
            var srcStream = new Readable(function() {
              return fs.createReadStream(srcFile.src);
            });
            archive.append(srcStream, { name: srcFile.dest }, function(err) {
              grunt.verbose.writeln('Archiving ' + srcFile.src + ' -> ' + '/' + srcFile.dest.cyan);
            });
        });

lazystream

Open Node Streams on demand.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular lazystream functions