SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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('...'));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top