var asset = new ProjectAsset('myFile', __dirname + '/image.jpg'), , ProjectAsset , , . , , .
, , node.js Transform Stream, , through2 :
module.exports = through2(function (chunk, enc, callback) {
this.push(chunk);
callback();
}))
var stream = fs.createReadStream(__dirname + '/image.jpg', { encoding: 'base64' })
.pipe(projectAsset)
.pipe(fs.createWriteStream(__dirname + '/image.jpg'));
, .
Factory
, , , .
var through2 = require('through2');
module.exports = function(someData) {
return through2(function (chunk, enc, callback) {
this.push(chunk);
callback();
});
}
var stream = fs.createReadStream(__dirname + '/image.jpg', { encoding: 'base64' })
.pipe(projectAsset({ foo: 'bar' }))
.pipe(fs.createWriteStream(__dirname + '/image.jpg'));