Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. // Install and import through2
  2. // npm install --save-dev through2
  3. const through = require('through2');
  4.  
  5. // Declare the function
  6. var myfn = function () {
  7. return through.obj(function (input, encoding, callback) {
  8. // Get current stream content.
  9. let content = String(input.contents);
  10.  
  11. // Do some transformations
  12. // ...
  13.  
  14. // Return a new stream with transformed content.
  15. let output = input.clone();
  16. output.contents = new Buffer(content);
  17.  
  18. // Resume next pipe.
  19. callback(null, output);
  20. });
  21. };
  22.  
  23. // Usage.
  24. gulp.src('...').pipe(myfn()).pipe(gulp.dest('...'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement