Created
September 5, 2016 22:32
-
-
Save Conduitry/872001307cd2963f3b144ec23db03462 to your computer and use it in GitHub Desktop.
Simple utility function for helping create gulp streams
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import stream from 'stream' | |
let Transform = stream.Transform | |
export default function makeStream(transform, flush) { | |
let stream = new Transform({ objectMode: true }) | |
let push = stream.push.bind(stream) | |
stream._transform = (file, enc, cb) => transform(file, push, cb) | |
if (flush) { | |
stream._flush = cb => flush(push, cb) | |
} | |
return stream | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment