I'm currently practicing with streams in Node.js using the modules through2
, concat-stream
and request
.
I set up a pipe chain like this:
request(process.argv[2])
.pipe(through(write, end))
.pipe(/*And */)
.pipe(/* Some */)
.pipe(/* more */)
.on("finish",function (){ #Do some stuff });
function write(buf, enc, nxt){
/*Push some data after some processing*/
}
function end(done){
done()
}
This is a static chain of pipes. Is it possible to, through some form of user input, dynamically specify a pipe-chain?
In pseudo code:
array_of_user_pipes = from_some_input;
pipe_library = {pipe_name:pipe_callback} object, loaded into application logic
perform the url request (fetch .txt file over the internet)
for all pipe in array_of_user_pipes do
fetch pipe from pipe_library (simple key look-up)
chain pipe to chain
execute the (dynamic) pipe chain
via Lennart Kloppenburg
No comments:
Post a Comment