Streams? • A talk to introduce the topic of streams in JavaScript, how this works in Node.js and how it didn't work out before. • You're my lab! by @zladuric
was there before • The present - what are we doing now • The future - how you can get and use this • The client - the browser side of things • The server - Streams API
as a whole blob • Takes up memory • When action is broken at 95%, redo the whole thing Streamed stuff • Just like regular, but chunked into bits • When broken, we can still reuse parts we got • PIPES!!1
a few years ago, we could not do much with streams in JS • Mostly for video/audio transfer with Flash, Java Applets On the server • Comes largely from unix network sockets • stdin, stdout, stderr • Created to streamline (yeah, I know) I/O operations • In web: Flash Media server, Red5 • Encoders/decoders, format converters • Bridges between backend services, more I/O WTF?
EventEmmiter (events and listeners/hooks) • var Readable = require('stream').Readable; – Implement your own _read(); • var Writable = require('stream').Writable; – Implement your own _write(); • var Duplex = implement both; • var Transform = convert input then pass to output – Implement _transform(); and flush();
• readable “I have stuff to be read.” • data “Here's a chunk.” • end “I'm all out, you've read it.” • close “Bye bye!” (file.close); • error “Pain starts here.”