Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-01-13 20:33:27 +0400
committerisaacs <i@izs.me>2012-01-13 20:41:06 +0400
commitc18fe966ddbeb66c8a9b9aa8ab4899166e6986f5 (patch)
tree8650e7575caff9d05e04352b78669dd81d21230d /node_modules/slide
parentb7ff884870958221eb52c5a600c101fab4c26781 (diff)
check in node_modules
Diffstat (limited to 'node_modules/slide')
-rw-r--r--node_modules/slide/.npmignore1
-rw-r--r--node_modules/slide/LICENSE23
-rw-r--r--node_modules/slide/README.md32
-rw-r--r--node_modules/slide/index.js1
-rw-r--r--node_modules/slide/lib/async-map-ordered.js65
-rw-r--r--node_modules/slide/lib/async-map.js56
-rw-r--r--node_modules/slide/lib/bind-actor.js16
-rw-r--r--node_modules/slide/lib/chain.js20
-rw-r--r--node_modules/slide/lib/slide.js3
-rw-r--r--node_modules/slide/nodejs-controlling-flow.pdfbin0 -> 167502 bytes
-rw-r--r--node_modules/slide/package.json19
11 files changed, 236 insertions, 0 deletions
diff --git a/node_modules/slide/.npmignore b/node_modules/slide/.npmignore
new file mode 100644
index 000000000..a13633799
--- /dev/null
+++ b/node_modules/slide/.npmignore
@@ -0,0 +1 @@
+*.pdf
diff --git a/node_modules/slide/LICENSE b/node_modules/slide/LICENSE
new file mode 100644
index 000000000..05a401094
--- /dev/null
+++ b/node_modules/slide/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2009, 2010, 2011 Isaac Z. Schlueter.
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/slide/README.md b/node_modules/slide/README.md
new file mode 100644
index 000000000..6e4be2f94
--- /dev/null
+++ b/node_modules/slide/README.md
@@ -0,0 +1,32 @@
+# Slide - a tiny flow control library
+
+Callbacks are simple and easy if you keep the pattern consistent.
+
+Check out the [slide
+presentation](http://github.com/isaacs/slide-flow-control/raw/master/nodejs-controlling-flow.pdf),
+or the [blog post](http://howto.no.de/flow-control-in-npm).
+
+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 use this util in [a real world program](http://npmjs.org/).
+
+You should use it as an example of how to write your own flow control
+utilities. You'll never fully appreciate a flow control lib that you
+didn't write yourself.
+
+## 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").asyncMap
+ , chain = require("slide").chain
+ // use the power!
+
+Enjoy!
diff --git a/node_modules/slide/index.js b/node_modules/slide/index.js
new file mode 100644
index 000000000..0a9277f6e
--- /dev/null
+++ b/node_modules/slide/index.js
@@ -0,0 +1 @@
+module.exports=require("./lib/slide")
diff --git a/node_modules/slide/lib/async-map-ordered.js b/node_modules/slide/lib/async-map-ordered.js
new file mode 100644
index 000000000..5cca79a82
--- /dev/null
+++ b/node_modules/slide/lib/async-map-ordered.js
@@ -0,0 +1,65 @@
+
+throw new Error("TODO: Not yet implemented.")
+
+/*
+usage:
+
+Like asyncMap, but only can take a single cb, and guarantees
+the order of the results.
+*/
+
+module.exports = asyncMapOrdered
+
+function asyncMapOrdered (list, fn, cb_) {
+ if (typeof cb_ !== "function") throw new Error(
+ "No callback provided to asyncMapOrdered")
+
+ if (typeof fn !== "function") throw new Error(
+ "No map function provided to asyncMapOrdered")
+
+ if (list === undefined || list === null) return cb_(null, [])
+ if (!Array.isArray(list)) list = [list]
+ if (!list.length) return cb_(null, [])
+
+ var errState = null
+ , l = list.length
+ , a = l
+ , res = []
+ , resCount = 0
+ , maxArgLen = 0
+
+ function cb (index) { return function () {
+ if (errState) return
+ var er = arguments[0]
+ var argLen = arguments.length
+ maxArgLen = Math.max(maxArgLen, argLen)
+ res[index] = argLen === 1 ? [er] : Array.apply(null, arguments)
+
+ // see if any new things have been added.
+ if (list.length > l) {
+ var newList = list.slice(l)
+ a += (list.length - l)
+ var oldLen = l
+ l = list.length
+ process.nextTick(function () {
+ newList.forEach(function (ar, i) { fn(ar, cb(i + oldLen)) })
+ })
+ }
+
+ if (er || --a === 0) {
+ errState = er
+ cb_.apply(null, [errState].concat(flip(res, resCount, maxArgLen)))
+ }
+ }}
+ // expect the supplied cb function to be called
+ // "n" times for each thing in the array.
+ list.forEach(function (ar) {
+ steps.forEach(function (fn, i) { fn(ar, cb(i)) })
+ })
+}
+
+function flip (res, resCount, argLen) {
+ var flat = []
+ // res = [[er, x, y], [er, x1, y1], [er, x2, y2, z2]]
+ // return [[x, x1, x2], [y, y1, y2], [undefined, undefined, z2]]
+
diff --git a/node_modules/slide/lib/async-map.js b/node_modules/slide/lib/async-map.js
new file mode 100644
index 000000000..1ced158e0
--- /dev/null
+++ b/node_modules/slide/lib/async-map.js
@@ -0,0 +1,56 @@
+
+/*
+usage:
+
+// do something to a list of things
+asyncMap(myListOfStuff, function (thing, cb) { doSomething(thing.foo, cb) }, cb)
+// do more than one thing to each item
+asyncMap(list, fooFn, barFn, cb)
+
+*/
+
+module.exports = asyncMap
+
+function asyncMap () {
+ var steps = Array.prototype.slice.call(arguments)
+ , list = steps.shift() || []
+ , cb_ = steps.pop()
+ if (typeof cb_ !== "function") throw new Error(
+ "No callback provided to asyncMap")
+ if (!list) return cb_(null, [])
+ if (!Array.isArray(list)) list = [list]
+ var n = steps.length
+ , data = [] // 2d array
+ , errState = null
+ , l = list.length
+ , a = l * n
+ if (!a) return cb_(null, [])
+ function cb (er) {
+ if (errState) return
+ var argLen = arguments.length
+ for (var i = 1; i < argLen; i ++) if (arguments[i] !== undefined) {
+ data[i - 1] = (data[i - 1] || []).concat(arguments[i])
+ }
+ // see if any new things have been added.
+ if (list.length > l) {
+ var newList = list.slice(l)
+ a += (list.length - l) * n
+ l = list.length
+ process.nextTick(function () {
+ newList.forEach(function (ar) {
+ steps.forEach(function (fn) { fn(ar, cb) })
+ })
+ })
+ }
+
+ if (er || --a === 0) {
+ errState = er
+ cb_.apply(null, [errState].concat(data))
+ }
+ }
+ // expect the supplied cb function to be called
+ // "n" times for each thing in the array.
+ list.forEach(function (ar) {
+ steps.forEach(function (fn) { fn(ar, cb) })
+ })
+}
diff --git a/node_modules/slide/lib/bind-actor.js b/node_modules/slide/lib/bind-actor.js
new file mode 100644
index 000000000..6a3707274
--- /dev/null
+++ b/node_modules/slide/lib/bind-actor.js
@@ -0,0 +1,16 @@
+module.exports = bindActor
+function bindActor () {
+ var args =
+ Array.prototype.slice.call
+ (arguments) // jswtf.
+ , obj = null
+ , fn
+ if (typeof args[0] === "object") {
+ obj = args.shift()
+ fn = args.shift()
+ if (typeof fn === "string")
+ fn = obj[ fn ]
+ } else fn = args.shift()
+ return function (cb) {
+ fn.apply(obj, args.concat(cb)) }
+}
diff --git a/node_modules/slide/lib/chain.js b/node_modules/slide/lib/chain.js
new file mode 100644
index 000000000..17b371149
--- /dev/null
+++ b/node_modules/slide/lib/chain.js
@@ -0,0 +1,20 @@
+module.exports = chain
+var bindActor = require("./bind-actor.js")
+chain.first = {} ; chain.last = {}
+function chain (things, cb) {
+ var res = []
+ ;(function LOOP (i, len) {
+ if (i >= len) return cb(null,res)
+ if (Array.isArray(things[i]))
+ things[i] = bindActor.apply(null,
+ things[i].map(function(i){
+ return (i===chain.first) ? res[0]
+ : (i===chain.last)
+ ? res[res.length - 1] : i }))
+ if (!things[i]) return LOOP(i + 1, len)
+ things[i](function (er, data) {
+ if (er) return cb(er, res)
+ if (data !== undefined) res = res.concat(data)
+ LOOP(i + 1, len)
+ })
+ })(0, things.length) }
diff --git a/node_modules/slide/lib/slide.js b/node_modules/slide/lib/slide.js
new file mode 100644
index 000000000..6e9ec2327
--- /dev/null
+++ b/node_modules/slide/lib/slide.js
@@ -0,0 +1,3 @@
+exports.asyncMap = require("./async-map")
+exports.bindActor = require("./bind-actor")
+exports.chain = require("./chain")
diff --git a/node_modules/slide/nodejs-controlling-flow.pdf b/node_modules/slide/nodejs-controlling-flow.pdf
new file mode 100644
index 000000000..ca12d60cb
--- /dev/null
+++ b/node_modules/slide/nodejs-controlling-flow.pdf
Binary files differ
diff --git a/node_modules/slide/package.json b/node_modules/slide/package.json
new file mode 100644
index 000000000..5cc2689e6
--- /dev/null
+++ b/node_modules/slide/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "slide",
+ "version": "1.1.3",
+ "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
+ "contributors": [
+ "S. Sriram <ssriram@gmail.com> (http://www.565labs.com)"
+ ],
+ "description": "A flow control lib small enough to fit on in a slide presentation. Derived live at Oak.JS",
+ "main": "./lib/slide.js",
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/slide-flow-control.git"
+ }
+}