Skip to content

Instantly share code, notes, and snippets.

@Conduitry
Created September 5, 2016 22:32
Show Gist options
  • Save Conduitry/872001307cd2963f3b144ec23db03462 to your computer and use it in GitHub Desktop.
Save Conduitry/872001307cd2963f3b144ec23db03462 to your computer and use it in GitHub Desktop.
Simple utility function for helping create gulp streams
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