https://github.com/catdad/glob-filestream
:page_facing_up: read a glob of files into a single stream
https://github.com/catdad/glob-filestream
glob npm stream
Last synced: 2 months ago
JSON representation
:page_facing_up: read a glob of files into a single stream
- Host: GitHub
- URL: https://github.com/catdad/glob-filestream
- Owner: catdad
- Created: 2016-04-07T23:14:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-15T05:02:44.000Z (over 6 years ago)
- Last Synced: 2024-12-15T14:03:55.927Z (6 months ago)
- Topics: glob, npm, stream
- Language: JavaScript
- Homepage:
- Size: 23.4 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# glob-filestream
[![Build][1]][2]
[![Test Coverage][3]][4]
[![Code Climate][5]][6]
[![Downloads][7]][8]
[![Version][9]][8]
[![Dependency Status][10]][11]
[![ISC License][12]][13][1]: https://travis-ci.org/catdad/glob-filestream.svg?branch=master
[2]: https://travis-ci.org/catdad/glob-filestream[3]: https://codeclimate.com/github/catdad/glob-filestream/badges/coverage.svg
[4]: https://codeclimate.com/github/catdad/glob-filestream/coverage[5]: https://codeclimate.com/github/catdad/glob-filestream/badges/gpa.svg
[6]: https://codeclimate.com/github/catdad/glob-filestream[7]: https://img.shields.io/npm/dm/glob-filestream.svg
[8]: https://www.npmjs.com/package/glob-filestream
[9]: https://img.shields.io/npm/v/glob-filestream.svg[10]: https://david-dm.org/catdad/glob-filestream.svg
[11]: https://david-dm.org/catdad/glob-filestream[12]: https://img.shields.io/npm/l/glob-filestream.svg
[13]: http://opensource.org/licenses/ISCReads a glob of files into a single stream.
## Install
npm install --save glob-filestream
## UsagePass in a glob or array of globs, and get all of the matched content in one stream.
```javascript
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:
```javascript
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.
```javascript
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:
```javascript
function transform(stream) {
return stream;
}
```## License
[ISC](http://opensource.org/licenses/ISC)