My talk at HTML5DevConf && FluentConf covering how I combined some basic functional programming techniques with node.js streams to abstract a streaming VFS zipping layer that can also (theoretically / eventually) run in the browser.
2. Who Am I?
HP webOS Framework Team
@CrabDude (Twitter, Github, etc…)
Organizer BayNode & Dallas.node
Author:
trycatch – async try/catch in node.js
stepup – step node.js control flow + trycatch
tiki – in-browser package manager
3. The Problem
VFS VFS VFS
hermesClient hermesClient hermesClient
hermesBuild 3rd Party API
hermes hermesDeploy
Ares
(browser)
4. The Goal
Don’t buffer any data
Don’t write to disk
Minimize latency
Allow reuse of functionality (e.g., readdir)
Functionality may be local or remote (e.g., getFolder)
5. Why node.js?
“Node's goal is to provide an easy way to build
scalable network programs.”
– nodejs.org
17. Lazy Streams: Higher Order Functions
A higher-order function is a function that does at least
one of the following:
Take one or more functions as input
output a function
22. We need…
We need to recursively zip a directory…
Let’s start with abstract implementation non-specific
functional versions of…
Filter paths from readdir
Filter directories from paths
Filter files from paths
Recursively return all file paths in a directory
23.
24. We need…
More “abstract implementation non-specific functional
versions” (errr…) of…
ls (aka readdir)
getFile (aka readFile)
getFolder (stream of gets)
25.
26. We need…
Yet More AINSFV of...
Zip a stream of files
Allow node.js streams to be piped to lazy streams
pipe(): lazy stream => node.js stream
pump(): node.js stream => lazy stream
34. Say whaaat?
node-browserify by @Substack does a lot of this already
Stream, Buffer, Path, etc…
We need…
Complete buffer implementation (browser has
TypedArrays & ArrayBuffer)
fs (browser has FileSystem API)
zlib…
inflate(), deflate(), gzip(), gunzip(), unzip()
35. Stay Tuned.
I’m currently porting the fs and buffer modules to
the browser, and eventually zlib.
http://github.com/crabdude/fs-browserify
http://github.com/crabdude/buffer-browserify
http://github.com/crabdude/zlib-browserify
36. We’re HIRING!
webOS Framework Team
If you think this is pretty cool…
Or you think I’M pretty cool…
Stop by the Enyo booth or talk to me afterwards.