Permalink
Browse files

Formatting the example, add README and slide pdf

  • Loading branch information...
isaacs committed Oct 29, 2010
1 parent 6c34abd commit 3a9aae9d05008a295b859342d767ab2e1321fef8
Showing with 34 additions and 7 deletions.
  1. +27 −0 README.md
  2. +7 −7 example/non-trivial-example.js
  3. BIN nodejs-controlling-flow.pdf
View
@@ -0,0 +1,27 @@
+# Slide - a tiny flow control library
+
+Callbacks are simple and easy if you keep the pattern consistent.
+
+Check out the [slide presentation](./nodejs-controlling-flow.pdf).
+
+You'll laugh when you see how little code is actually in this thing.
+It's so not-enterprisey, you won't believe it. It does almost nothing,
+but it's super handy.
+
+I actually use an earlier version of this util in
+[a real world program](http://npmjs.org/).
+
+## Installation
+
+Just copy the files into your project, and use them that way, or
+you can do this:
+
+ npm install slide
+
+and then:
+
+ var asyncMap = require("slide/async-map")
+ , chain = require("slide/chain")
+ // use the power!
+
+Enjoy!
@@ -23,7 +23,9 @@ function removeFiles (dir, files, cb) {
}
function readFiles (dir, files, cb) {
- asyncMap(files.map(function (f) { return dir+"/"+f }), fs.readFile, cb)
+ asyncMap(files.map(function (f) {
+ return dir+"/"+f
+ }), fs.readFile, cb)
}
function sum (numbers, cb) {
return cb(null, numbers.reduce(function(x,y){
@@ -38,12 +40,10 @@ function ping (method, host, port, path, data, cb) {
req.on("response", function (resp) {
var b = ""
resp.on("data", function (c) { b += c })
- resp.on("end", function () {
- if (resp.statusCode !== 200) {
- cb(new Error("Failed "+JSON.stringify(resp.headers,0,2)+"\n"+b))
- } else {
- cb(null, b)
- }
+ .on("end", function () {
+ if (resp.statusCode !== 200)
+ cb(new Error("Failed"))
+ else cb(null, b)
})
})
req.end(data)
View
Binary file not shown.

0 comments on commit 3a9aae9

Please sign in to comment.