Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Install and import through2
- // npm install --save-dev through2
- const through = require('through2');
- // Declare the function
- var myfn = function () {
- return through.obj(function (input, encoding, callback) {
- // Get current stream content.
- let content = String(input.contents);
- // Do some transformations
- // ...
- // Return a new stream with transformed content.
- let output = input.clone();
- output.contents = new Buffer(content);
- // Resume next pipe.
- callback(null, output);
- });
- };
- // Usage.
- gulp.src('...').pipe(myfn()).pipe(gulp.dest('...'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement