You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
518 B
28 lines
518 B
var through2 = require('through2').obj |
|
var bl = require('bl') |
|
|
|
module.exports = vinylBuffer |
|
|
|
function vinylBuffer() { |
|
var stream = through2(write) |
|
|
|
return stream |
|
|
|
function write(file, _, next) { |
|
if (file.isNull()) return push(file, next) |
|
if (file.isBuffer()) return push(file, next) |
|
|
|
file.contents.pipe(bl(function(err, data) { |
|
if (err) return next(err) |
|
|
|
file.contents = data |
|
|
|
push(file, next) |
|
})) |
|
} |
|
|
|
function push(file, next) { |
|
stream.push(file) |
|
next() |
|
} |
|
}
|
|
|