-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from kevva/readable-stream
Use readable-stream instead of through2
- Loading branch information
Showing
2 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
'use strict'; | ||
|
||
var objectAssign = require('object-assign'); | ||
var through = require('through2'); | ||
var Transform = require('readable-stream/transform'); | ||
|
||
module.exports = function (opts) { | ||
opts = opts || {}; | ||
|
||
return through.obj(function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
return new Transform({ | ||
objectMode: true, | ||
transform: function (file, enc, cb) { | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
|
||
if (file.isStream()) { | ||
cb(new Error('Streaming is not supported')); | ||
return; | ||
} | ||
if (file.isStream()) { | ||
cb(new Error('Streaming is not supported')); | ||
return; | ||
} | ||
|
||
cb(null, objectAssign(file, opts)); | ||
cb(null, objectAssign(file, opts)); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters