Skip to content

Instantly share code, notes, and snippets.

@hadashiA
Created January 27, 2014 14:40
Show Gist options
  • Save hadashiA/8649686 to your computer and use it in GitHub Desktop.
Save hadashiA/8649686 to your computer and use it in GitHub Desktop.
一本のReadableStreamを、二本のReadableStreamにする
fs = require 'fs'
gm = require 'gm'
im = gm.subClass imageMagick: true
{PassThrough} = require 'stream'
stream = fs.createReadStream '/Users/hadashi/tmp/20.png'
stream2 = new PassThrough
stream3 = new PassThrough
stream.on 'data', (data) ->
stream2.write data
stream3.write data
stream.on 'end', ->
stream2.end()
stream3.end()
im(stream2)
.size (err, size) ->
console.log arguments
im(stream3)
.size (err, size) ->
console.log arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment