/compass/005_compass/compass/node_modules/array-series/README.md |
@@ -0,0 +1,76 @@ |
# Array Series [![Build Status](https://travis-ci.org/component/array-series.png)](https://travis-ci.org/component/array-series) |
|
Call an array of asynchronous functions in series |
|
### API |
|
#### series(fns[, context[, callback]]) |
|
```js |
var series = require('array-series') |
|
series([ |
function (done) { |
done() |
} |
], this, function (err) { |
|
}) |
``` |
|
#### fns |
|
`fns` is an array of functions to call in series. |
The argument signature should be: |
|
```js |
function (done) { |
done(new Error()) |
// or |
done() |
} |
``` |
|
That is, each function should only take a `done` as an argument. |
Each callback should only take an optional `Error` as an argument. |
|
#### context |
|
Optional context to pass to each `fn`. |
Basically `fn.call(context, done)`. |
|
#### callback(err) |
|
```js |
function (err) { |
|
} |
``` |
|
Only argument is an `Error` argument. |
It will return the first error in the series of functions that returns an error, |
and no function after will be called. |
|
### License |
|
The MIT License (MIT) |
|
Copyright (c) 2013 Jonathan Ong me@jongleberry.com |
|
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. |
/compass/005_compass/compass/node_modules/array-series/package.json |
@@ -0,0 +1,48 @@ |
{ |
"_from": "array-series@~0.1.5", |
"_id": "array-series@0.1.5", |
"_inBundle": false, |
"_integrity": "sha1-3103v8XC7wdV4qpPkv6ufUtaly8=", |
"_location": "/array-series", |
"_phantomChildren": {}, |
"_requested": { |
"type": "range", |
"registry": true, |
"raw": "array-series@~0.1.5", |
"name": "array-series", |
"escapedName": "array-series", |
"rawSpec": "~0.1.5", |
"saveSpec": null, |
"fetchSpec": "~0.1.5" |
}, |
"_requiredBy": [ |
"/gm" |
], |
"_resolved": "https://registry.npmjs.org/array-series/-/array-series-0.1.5.tgz", |
"_shasum": "df5d37bfc5c2ef0755e2aa4f92feae7d4b5a972f", |
"_spec": "array-series@~0.1.5", |
"_where": "/Users/horia.corcalciuc/Documents/Development/corrade-nucleus-nucleons/compass/005_compass/compass/node_modules/gm", |
"author": { |
"name": "Jonathan Ong", |
"email": "me@jongleberry.com", |
"url": "http://jongleberry.com" |
}, |
"bugs": { |
"url": "https://github.com/component/array-series/issues", |
"email": "me@jongleberry.com" |
}, |
"bundleDependencies": false, |
"deprecated": false, |
"description": "Call an array of asynchronous functions in series", |
"homepage": "https://github.com/component/array-series#readme", |
"license": "MIT", |
"name": "array-series", |
"repository": { |
"type": "git", |
"url": "git+https://github.com/component/array-series.git" |
}, |
"scripts": { |
"test": "node test" |
}, |
"version": "0.1.5" |
} |
/compass/005_compass/compass/node_modules/array-series/test.js |
@@ -0,0 +1,88 @@ |
var assert = require('assert') |
var series = require('./') |
|
var a, b, c |
|
series([ |
function (done) { |
a = 1 |
process.nextTick(done) |
check('a') |
}, |
function (done) { |
b = 2 |
process.nextTick(done) |
check('b') |
}, |
function (done) { |
c = 3 |
process.nextTick(done) |
check('c') |
} |
], function (err) { |
assert.ifError(err) |
assert.equal(a, 1) |
assert.equal(b, 2) |
assert.equal(c, 3) |
}) |
|
function check(x) { |
switch (x) { |
case 'a': |
assert.equal(a, 1) |
assert.equal(b, undefined) |
assert.equal(c, undefined) |
break |
case 'b': |
assert.equal(a, 1) |
assert.equal(b, 2) |
assert.equal(c, undefined) |
break |
case 'c': |
assert.equal(a, 1) |
assert.equal(b, 2) |
assert.equal(c, 3) |
break |
} |
} |
|
var context = 'hello' |
series([function (done) { |
assert.equal(this, context) |
done() |
}], context) |
|
var finished |
series([], function (err) { |
finished = true |
}) |
|
process.nextTick(function () { |
if (!finished) |
throw new Error('Failed with no functions.'); |
}) |
|
var r, d, o |
series([ |
function (done) { |
r = 1 |
process.nextTick(done) |
}, |
function (done) { |
d = 0 |
process.nextTick(function () { |
done(new Error('message')) |
}) |
}, |
function (done) { |
o = 0 |
process.nextTick(done) |
} |
], function (err) { |
assert.equal(err.message, 'message') |
assert.equal(r, 1) |
assert.equal(d, 0) |
assert.equal(o, undefined) |
}) |
|
console.log('Array series tests pass!') |