Created
November 4, 2013 21:46
-
-
Save gerred/7309715 to your computer and use it in GitHub Desktop.
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
fs = require 'fs' | |
noflo = require 'noflo' | |
split = require 'split' | |
class ReadFileStream extends noflo.Component | |
constructor: -> | |
@inPorts = | |
in: new noflo.Port() | |
@outPorts = | |
out: new noflo.Port() | |
error: new noflo.Port() | |
@inPorts.in.on 'data', (data) => | |
@readStream = fs.createReadStream(data, encoding: 'utf-8') | |
@readStream.pipe(split()).on 'data', (line) => | |
@outPorts.out.send line | |
@readStream.on 'end', => | |
@outPorts.out.disconnect() | |
exports.getComponent = -> new ReadFileStream |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment