0.3.2 • Published 5 years ago

glob-filestream v0.3.2

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

glob-filestream

Build Test Coverage Code Climate Downloads Version Dependency Status ISC License

Reads a glob of files into a single stream.

Install

npm install --save glob-filestream

Usage

Pass in a glob or array of globs, and get all of the matched content in one stream.

var globfile = require('glob-filestream');

var stream = globfile('*.txt');

// read like a regular filestream

var data = [];

stream.on('data', function(chunk) {
    data.push(chunk);
});

stream.on('end', function() {
    console.log(Buffer.concat(data).toString());
});

Files will be read and piped as-is, but sometimes, you may want to separate individual files with a new line. You can use the options for that, as such:

var stream = globfile('*.txt', {
    appendNewLine: true
});

Every once in a while, you might find the need to transform individual files as you read them. There is an option for that as well.

var globfile = require('glob-filestream');
var ensureGunzip = require('ensure-gunzip');

var stream = globfile(['*.txt.gzip', '*.txt'], {
    transform: ensureGunzip
});

// read `stream`, containing all plain text files

Transform is a function that takes a stream as a parameter and returns a new stream. The identify transform function would look like this:

function transform(stream) {
    return stream;
}

License

ISC

0.3.2

5 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago