Projektstart

This commit is contained in:
2026-01-22 15:49:12 +01:00
parent 7212eb6f7a
commit 57e5f652f8
10637 changed files with 2598792 additions and 64 deletions

27
backend/node_modules/steed/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,27 @@
# Logs
logs
*.log
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules

13
backend/node_modules/steed/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,13 @@
language: node_js
sudo: false
node_js:
- "5"
- "4"
- "iojs"
- "0.12"
- "0.11"
- "0.10"
after_script:
npm run coverage

22
backend/node_modules/steed/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Matteo Collina
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.

670
backend/node_modules/steed/README.md generated vendored Normal file
View File

@@ -0,0 +1,670 @@
![logo][logo-url]
# steed
[![npm version][npm-badge]][npm-url]
[![Build Status][travis-badge]][travis-url]
[![Coverage Status][coveralls-badge]][coveralls-url]
[![Dependency Status][david-badge]][david-url]
Horsepower for your modules.
__Steed__ is an alternative to [async](http://npm.im/async) that is
~50-100% faster. It is not currently on-par with async in term of features.
Please help us!
* <a href="#install">Installation</a>
* <a href="#api">API</a>
* <a href="#caveats">Caveats</a>
* <a href="#why">Why it is so fast?</a>
* <a href="#acknowledgements">Acknowledgements</a>
* <a href="#licence">Licence &amp; copyright</a>
[![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard)
Watch Matteo presenting Steed at Node.js Interactive 2015: https://www.youtube.com/watch?v=_0W_822Dijg.
## Install
`npm i steed --save`
## API
* <a href="#steed"><code><b>steed()</b></code></a>
* <a href="#parallel"><code>steed#<b>parallel()</b></code></a>
* <a href="#series"><code>steed#<b>series()</b></code></a>
* <a href="#waterfall"><code>steed#<b>waterfall()</b></code></a>
* <a href="#each"><code>steed#<b>each()</b></code></a>
* <a href="#eachSeries"><code>steed#<b>eachSeries()</b></code></a>
* <a href="#map"><code>steed#<b>map()</b></code></a>
* <a href="#mapSeries"><code>steed#<b>mapSeries()</b></code></a>
* <a href="#queue"><code>steed#<b>queue()</b></code></a>
-------------------------------------------------------
<a name="steed"></a>
### steed()
Build an instance of steed, this step is not needed but welcomed for
greater performance. Each steed utility likes being used for the same
purpose.
-------------------------------------------------------
<a name="parallel"></a>
### steed.parallel([that,] tasks[, done(err, results)])
Executes a series of tasks in parallel.
`tasks` can either be an array of functions, or an object where each
property is a function. `done` will be called with the results.
The `that` argument will set `this` for each task and `done` callback.
Uses [fastparallel](http://npm.im/fastparallel).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
steed.parallel([
function a (cb){
cb(null, 'a');
},
function b (cb){
cb(null, 'b');
}
], function(err, results){
// results is ['a', 'b']
})
// an example using an object instead of an array
steed.parallel({
a: function a1 (cb){
cb(null, 1)
},
b: function b1 (cb){
cb(null, 2)
}
}, function(err, results) {
// results is { a: 1, b: 2}
})
// an example using that parameter
// preferred form for max speed
function run (prefix, a, b, cb) {
steed.parallel(new State(prefix, a, b, cb), [aT, bT], doneT)
}
// can be optimized by V8 using an hidden class
function State (prefix, a, b, cb) {
this.a = a
this.b = b
this.cb = cb
this.prefix = prefix
}
// because it is not a closure inside run()
// v8 can optimize this function
function aT (cb){
cb(null, this.a);
}
// because it is not a closure inside run()
// v8 can optimize this function
function bT (cb){
cb(null, this.b);
}
// because it is not a closure inside run()
// v8 can optimize this function
function doneT (err, results) {
if (results) {
results.unshift(this.prefix)
results = results.join(' ')
}
this.cb(err, results)
}
run('my name is', 'matteo', 'collina', console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 1781ms
* `async.parallel`: 3484ms
* `neoAsync.parallel`: 2162ms
* `insync.parallel`: 10252ms
* `items.parallel`: 3725ms
* `parallelize`: 2928ms
* `fastparallel` with results: 2139ms
These benchmarks where taken on node v4.1.0, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="series"></a>
### steed.series([that,] tasks[, done(err, results)])
Executes a series of tasks in series.
`tasks` can either be an array of functions, or an object where each
property is a function. `done` will be called with the results.
The `that` argument will set `this` for each task and `done` callback.
Uses [fastseries](http://npm.im/fastseries).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
steed.series([
function a (cb){
cb(null, 'a');
},
function b (cb){
cb(null, 'b');
}
], function(err, results){
// results is ['a', 'b']
})
// an example using an object instead of an array
steed.series({
a: function a (cb){
cb(null, 1)
},
b: function b (cb){
cb(null, 2)
}
}, function(err, results) {
// results is { a: 1, b: 2}
})
// an example using that parameter
// preferred form for max speed
function run (prefix, a, b, cb) {
steed.series(new State(prefix, a, b, cb), [aT, bT], doneT)
}
// can be optimized by V8 using an hidden class
function State (prefix, a, b, cb) {
this.a = a
this.b = b
this.cb = cb
this.prefix = prefix
}
// because it is not a closure inside run()
// v8 can optimize this function
function aT (cb){
cb(null, this.a);
}
// because it is not a closure inside run()
// v8 can optimize this function
function bT (cb){
cb(null, this.b);
}
// because it is not a closure inside run()
// v8 can optimize this function
function doneT (err, results) {
if (results) {
results.unshift(this.prefix)
results = results.join(' ')
}
this.cb(err, results)
}
run('my name is', 'matteo', 'collina', console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 3887ms
* `async.series`: 5981ms
* `neoAsync.series`: 4338ms
* `fastseries` with results: 4096ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="waterfall"></a>
### steed.waterfall(tasks[, done(err, ...)])
Runs the functions in `tasks` in series, each passing their result to
the next task in the array. Quits early if any of the tasks errors.
Uses [fastfall](http://npm.im/fastfall).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
steed.waterfall([
function a (cb) {
console.log('called a')
cb(null, 'a')
},
function b (a, cb) {
console.log('called b with:', a)
cb(null, 'a', 'b')
},
function c (a, b, cb) {
console.log('called c with:', a, b)
cb(null, 'a', 'b', 'c')
}], function result (err, a, b, c) {
console.log('result arguments', arguments)
})
// preferred version for maximum speed
function run (word, cb) {
steed.waterfall(new State(cb), [
aT, bT, cT,
], cb)
}
// can be optimized by V8 using an hidden class
function State (value) {
this.value = value
}
// because it is not a closure inside run()
// v8 can optimize this function
function aT (cb) {
console.log(this.value)
console.log('called a')
cb(null, 'a')
}
// because it is not a closure inside run()
// v8 can optimize this function
function bT (a, cb) {
console.log('called b with:', a)
cb(null, 'a', 'b')
}
// because it is not a closure inside run()
// v8 can optimize this function
function cT (a, b, cb) {
console.log('called c with:', a, b)
cb(null, 'a', 'b', 'c')
}
```
Benchmark for doing 3 calls `setImmediate` 100 thousands times:
* non-reusable setImmediate: 418ms
* `async.waterfall`: 1174ms
* `run-waterfall`: 1432ms
* `insync.wasterfall`: 1174ms
* `neo-async.wasterfall`: 469ms
* `waterfallize`: 749ms
* `fastfall`: 452ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="each"></a>
### steed.each([that,] array, iterator(item, cb), [, done()])
Iterate over all elements of the given array asynchronosly and in
parallel.
Calls `iterator` with an item and a callback. Calls `done` when all have
been processed.
The `that` argument will set `this` for each task and `done` callback.
`each` does not handle errors, if you need errors, use [`map`](#map).
Uses [fastparallel](http://npm.im/fastparallel).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
var input = [1, 2, 3]
var factor = 2
steed.each(input, function (num, cb) {
console.log(num * factor)
setImmediate(cb)
}, function () {
console.log('done')
})
// preferred version for max speed
function run (factor, args, cb) {
steed.each(new State(factor), work, cb)
}
// can be optimizied by V8 using an hidden class
function State (factor) {
this.factor = factor
}
// because it is not a closure inside run()
// v8 can optimize this function
function work (num, cb) {
console.log(num * this.factor)
cb()
}
run(factor, input, console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 1781ms
* `async.each`: 2621ms
* `neoAsync.each`: 2156ms
* `insync.parallel`: 10252ms
* `insync.each`: 2397ms
* `fastparallel` each: 1941ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="eachSeries"></a>
### steed.eachSeries([that,] array, iterator(item, cb), [, done(err)])
Iterate over all elements of the given array asynchronously and in
series.
Calls `iterator` with an item and a callback. Calls `done` when all have
been processed.
The `that` argument will set `this` for each task and `done` callback.
`eachSeries` does not handle errors, if you need errors, use [`mapSeries`](#mapSeries).
Uses [fastseries](http://npm.im/fastseries).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
var input = [1, 2, 3]
var factor = 2
steed.eachSeries(input, function (num, cb) {
console.log(num * factor)
setImmediate(cb)
}, function (err) {
console.log(err)
})
// preferred version for max speed
function run (factor, args, cb) {
steed.eachSeries(new State(factor), work, cb)
}
// can be optimizied by V8 using an hidden class
function State (factor) {
this.factor = factor
}
// because it is not a closure inside run()
// v8 can optimize this function
function work (num, cb) {
console.log(num * this.factor)
cb()
}
run(factor, input, console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 3887ms
* `async.mapSeries`: 5540ms
* `neoAsync.eachSeries`: 4195ms
* `fastseries` each: 4168ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="map"></a>
### steed.map([that,] array, iterator(item, cb), [, done(err, results)])
Performs a map operation over all elements of the given array asynchronously and in
parallel. The result is an a array where all items have been replaced by
the result of `iterator`.
The `that` argument will set `this` for each task and `done` callback.
Calls `iterator` with an item and a callback. Calls `done` when all have
been processed.
Uses [fastparallel](http://npm.im/fastparallel).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
var input = [1, 2, 3]
var factor = 2
steed.map(input, function (num, cb) {
setImmediate(cb, null, num * factor)
}, function (err, results) {
if (err) { throw err }
console.log(results.reduce(sum))
})
function sum (acc, num) {
return acc + num
}
// preferred version for max speed
function run (factor, args, cb) {
steed.map(new State(factor, cb), args, work, done)
}
// can be optimizied by V8 using an hidden class
function State (factor, cb) {
this.factor = factor
this.cb = cb
}
// because it is not a closure inside run()
// v8 can optimize this function
function work (num, cb) {
setImmediate(cb, null, num * this.factor)
}
function done (err, results) {
results = results || []
this.cb(err, results.reduce(sum))
}
run(2, [1, 2, 3], console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 1781ms
* `async.map`: 3054ms
* `neoAsync.map`: 2080ms
* `insync.map`: 9700ms
* `fastparallel` map: 2102ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="mapSeries"></a>
### steed.mapSeries([that,] array, iterator(item, cb), [, done(err, results)])
Performs a map operation over all elements of the given array asynchronosly and in
series. The result is an a array where all items have been replaced by
the result of `iterator`.
Calls `iterator` with an item and a callback. Calls `done` when all have
been processed.
The `that` argument will set `this` for each task and `done` callback.
Uses [fastseries](http://npm.im/fastseries).
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
var input = [1, 2, 3]
var factor = 2
steed.mapSeries(input, function (num, cb) {
setImmediate(cb, null, num * factor)
}, function (err, results) {
if (err) { throw err }
console.log(results.reduce(sum))
})
function sum (acc, num) {
return acc + num
}
// preferred version for max speed
function run (factor, args, cb) {
steed.mapSeries(new State(factor, cb), args, work, done)
}
// can be optimizied by V8 using an hidden class
function State (factor, cb) {
this.factor = factor
this.cb = cb
}
// because it is not a closure inside run()
// v8 can optimize this function
function work (num, cb) {
setImmediate(cb, null, num * this.factor)
}
function done (err, results) {
results = results || []
this.cb(err, results.reduce(sum))
}
run(2, [1, 2, 3], console.log)
```
Benchmark for doing 3 calls `setImmediate` 1 million times:
* non-reusable `setImmediate`: 3887ms
* `async.mapSeries`: 5540ms
* `neoAsync.mapSeries`: 4237ms
* `fastseries` map: 4032ms
These benchmarks where taken on node v4.2.2, on a MacBook
Pro Retina Mid 2014 (i7, 16GB of RAM).
-------------------------------------------------------
<a name="queue"></a>
### steed.queue(worker, concurrency)
Creates a new queue. See [fastq](http://npm.im/fastq) for full API.
Arguments:
* `worker`, worker function, it would be called with `that` as `this`,
if that is specified.
* `concurrency`, number of concurrent tasks that could be executed in
parallel.
Example:
```js
var steed = require('steed')()
// or
// var steed = require('steed')
var queue = steed.queue(worker, 1)
queue.push(42, function (err, result) {
if (err) { throw err }
console.log('the result is', result)
})
function worker (arg, cb) {
cb(null, arg * 2)
}
```
Benchmarks (1 million tasks):
* setImmedidate: 1313ms
* fastq: 1462ms
* async.queue: 3989ms
Obtained on node 4.2.2, on a MacBook Pro 2014 (i7, 16GB of RAM).
## Caveats
This library works by caching the latest used function, so that running a new parallel
does not cause **any memory allocations**.
The `done` function will be called only once, even if more than one error happen.
__Steed__ has no safety checks: you should be responsible to avoid sync
functions and so on. Also arguments type checks are not included, so be
careful in what you pass.
<a name="why"></a>
## Why it is so fast?
1. This library is caching functions a lot. We invented a technique to
do so, and packaged it in a module: [reusify](http://npm.im/reusify).
2. V8 optimizations: thanks to caching, the functions can be optimized by V8
(if they are optimizable, and we took great care of making them so).
3. Don't use arrays if you just need a queue. A linked list implemented via
objects is much faster if you do not need to access elements in between.
## Acknowledgements
Steed is sponsored by [nearForm](http://nearform.com).
The steed logo was created, with thanks, by [Dean McDonnell](https://github.com/mcdonnelldean)
## License
MIT
[logo-url]: https://raw.githubusercontent.com/mcollina/steed/master/assets/banner.png
[npm-badge]: https://badge.fury.io/js/steed.svg
[npm-url]: https://badge.fury.io/js/steed
[travis-badge]: https://api.travis-ci.org/mcollina/steed.svg
[travis-url]: https://travis-ci.org/mcollina/steed
[coveralls-badge]:https://coveralls.io/repos/mcollina/steed/badge.svg?branch=master&service=github
[coveralls-url]: https://coveralls.io/github/mcollina/steed?branch=master
[david-badge]: https://david-dm.org/mcollina/steed.svg
[david-url]: https://david-dm.org/mcollina/steed

BIN
backend/node_modules/steed/assets/banner-inverse.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

20
backend/node_modules/steed/assets/banner-inverse.svg generated vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 34 KiB

BIN
backend/node_modules/steed/assets/banner.afdesign generated vendored Normal file

Binary file not shown.

BIN
backend/node_modules/steed/assets/banner.png generated vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

20
backend/node_modules/steed/assets/banner.svg generated vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 35 KiB

43
backend/node_modules/steed/bench.js generated vendored Normal file
View File

@@ -0,0 +1,43 @@
var max = 1000000
var steed = require('./')
var bench = require('fastbench')
var neo = require('neo-async')
var funcs = [somethingA, somethingA, somethingA]
function benchSteedParallel (done) {
steed.parallel(funcs, done)
}
function benchNeoParallel (done) {
neo.parallel(funcs, done)
}
var nextDone
var nextCount
function benchSetImmediate (done) {
nextCount = 3
nextDone = done
setImmediate(somethingImmediate)
setImmediate(somethingImmediate)
setImmediate(somethingImmediate)
}
function somethingImmediate () {
nextCount--
if (nextCount === 0) {
nextDone()
}
}
function somethingA (cb) {
setImmediate(cb)
}
var run = bench([
benchSetImmediate,
benchNeoParallel,
benchSteedParallel
], max)
run(run)

43
backend/node_modules/steed/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "steed",
"version": "1.1.3",
"description": "horsepower for your modules",
"main": "steed.js",
"scripts": {
"test": "standard && tape test.js | tap-spec",
"coverage": "istanbul cover tape test.js; cat coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mcollina/steed.git"
},
"keywords": [
"control",
"flow",
"async",
"series",
"parallel"
],
"author": "Matteo Collina <hello@matteocollina.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/mcollina/steed/issues"
},
"homepage": "https://github.com/mcollina/steed#readme",
"devDependencies": {
"coveralls": "^2.11.6",
"fastbench": "^1.0.0",
"istanbul": "^0.4.1",
"neo-async": "^1.7.0",
"standard": "^5.4.1",
"tap-spec": "^4.1.0",
"tape": "^4.2.2"
},
"dependencies": {
"fastfall": "^1.5.0",
"fastparallel": "^2.2.0",
"fastq": "^1.3.0",
"fastseries": "^1.7.0",
"reusify": "^1.0.0"
}
}

126
backend/node_modules/steed/steed.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
'use strict'
var nr = { results: false }
var fastparallel = require('fastparallel')
var fastseries = require('fastseries')
var fastfall = require('fastfall')
var fastq = require('fastq')
function steed (context) {
if (!context) {
context = {}
}
var _parNr = fastparallel(nr)
var _serNr = fastseries(nr)
var _par = fastparallel()
var _ser = fastseries()
context.each = each
context.map = map
context.eachSeries = eachSeries
context.mapSeries = mapSeries
context.parallel = parallel
context.series = series
context.waterfall = fastfall()
context.queue = fastq
return context
function each (that, array, func, cb) {
if (!func || typeof func === 'function' && typeof array === 'function') {
cb = func
func = array
array = that
that = null
}
_parNr(that, func, array, cb)
}
function eachSeries (that, array, func, cb) {
if (!func || typeof func === 'function' && typeof array === 'function') {
cb = func
func = array
array = that
that = null
}
_serNr(that, func, array, cb)
}
function map (that, array, func, cb) {
if (!func || typeof func === 'function' && typeof array === 'function') {
cb = func
func = array
array = that
that = null
}
_par(that, func, array, cb)
}
function mapSeries (that, array, func, cb) {
if (!func || typeof func === 'function' && typeof array === 'function') {
cb = func
func = array
array = that
that = null
}
_ser(that, func, array, cb)
}
function parallel (that, funcs, cb) {
if (!funcs || typeof funcs === 'function') {
cb = funcs
funcs = that
that = null
}
if (Array.isArray(funcs)) {
_par(that, funcs, null, cb)
} else {
_handleObjectMap(that, _par, funcs, cb)
}
}
function series (that, funcs, cb) {
if (!funcs || typeof funcs === 'function') {
cb = funcs
funcs = that
that = null
}
if (Array.isArray(funcs)) {
_ser(that, funcs, null, cb)
} else {
_handleObjectMap(that, _ser, funcs, cb)
}
}
}
function _handleObjectMap (that, iterator, funcs, cb) {
var keys = Object.keys(funcs)
iterator(new MapStatus(keys, funcs, cb), callNamedFunc, keys, mapResults)
}
function MapStatus (keys, funcs, cb) {
this.cb = cb
this.keys = keys
this.funcs = funcs
this.results = {}
}
function callNamedFunc (key, cb) {
this.funcs[key](cb)
}
function mapResults (err, results) {
if (err) { return this.cb(err) }
var keys = this.keys
var toReturn = {}
for (var i = 0; i < keys.length; i++) {
toReturn[keys[i]] = results[i]
}
this.cb(null, toReturn)
}
module.exports = steed(steed)

584
backend/node_modules/steed/test.js generated vendored Normal file
View File

@@ -0,0 +1,584 @@
'use strict'
var test = require('tape')
var factory = require('./')
function buildTest (steed) {
test('each', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
steed.each(input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.notOk(snd, 'no second argument')
t.equal(3, i, 'iterated over all inputs')
})
})
test('each with this', function (t) {
t.plan(13)
var input = [1, 2, 3]
var i = 0
var obj = {}
steed.each(obj, input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.equal(obj, this, 'this is set')
t.error(err, 'no error')
t.notOk(snd, 'no second argument')
t.equal(3, i, 'iterated over all inputs')
})
})
test('each with this without a done callback', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var obj = {}
steed.each(obj, input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('each without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
steed.each(input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('map', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
steed.map(input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('map with this', function (t) {
t.plan(13)
var input = [1, 2, 3]
var i = 0
var obj = {}
steed.map(obj, input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.equal(obj, this, 'this is set')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('map with this without a done callback', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var obj = {}
steed.map(obj, input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('map without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
steed.map(input, function (num, cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('eachSeries', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var count = 0
steed.eachSeries(input, function (num, cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
t.equal(input[i++], num)
cb(null, input[i] * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.notOk(snd, 'no second argument')
t.equal(3, i, 'iterated over all inputs')
})
})
test('eachSeries with this', function (t) {
t.plan(13)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
steed.eachSeries(obj, input, function (num, cb) {
t.equal(obj, this, 'this is set')
t.equal(count++, i, 'calls in series')
setImmediate(function () {
t.equal(input[i++], num)
cb(null, input[i] * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.notOk(snd, 'no second argument')
t.equal(obj, this, 'this is set')
t.equal(3, i, 'iterated over all inputs')
})
})
test('eachSeries with this without a done callback', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
steed.eachSeries(obj, input, function (num, cb) {
t.equal(obj, this, 'this is set')
t.equal(count++, i, 'calls in series')
setImmediate(function () {
t.equal(input[i++], num)
cb(null, input[i] * 2)
})
})
})
test('eachSeries without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var count = 0
steed.eachSeries(input, function (num, cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
t.equal(input[i++], num)
cb(null, input[i] * 2)
})
})
})
test('mapSeries', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var count = 0
steed.mapSeries(input, function (num, cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('mapSeries with this', function (t) {
t.plan(13)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
steed.mapSeries(obj, input, function (num, cb) {
t.equal(count++, i, 'calls in series')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
}, function (err, snd) {
t.error(err, 'no error')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(obj, this, 'this is set')
t.equal(3, i, 'iterated over all inputs')
})
})
test('mapSeries with this without a done callback', function (t) {
t.plan(9)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
steed.mapSeries(obj, input, function (num, cb) {
t.equal(count++, i, 'calls in series')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('mapSeries without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var count = 0
steed.mapSeries(input, function (num, cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
var res = input[i++]
t.equal(res, num)
cb(null, res * 2)
})
})
})
test('parallel', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
function myfunc (cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.parallel([myfunc, myfunc, myfunc], function (err, snd) {
t.error(err, 'no error')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('parallel with this', function (t) {
t.plan(10)
var input = [1, 2, 3]
var i = 0
var obj = {}
function myfunc (cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.parallel(obj, [myfunc, myfunc, myfunc], function (err, snd) {
t.error(err, 'no error')
t.equal(obj, this, 'this is set')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('parallel with this without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var obj = {}
function myfunc (cb) {
t.equal(0, i, 'calls in parallel')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.parallel(obj, [myfunc, myfunc, myfunc])
})
test('parallel without a done callback', function (t) {
t.plan(3)
var input = [1, 2, 3]
var i = 0
function myfunc (cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.parallel([myfunc, myfunc, myfunc])
})
test('parallel with an object', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
function myfunc (cb) {
t.equal(0, i, 'calls in parallel')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.parallel({
a: myfunc,
b: myfunc,
c: myfunc
}, function (err, snd) {
t.error(err, 'no error')
t.deepEqual({
a: 2,
b: 4,
c: 6
}, snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('series', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var count = 0
function myfunc (cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.series([myfunc, myfunc, myfunc], function (err, snd) {
t.error(err, 'no error')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('series with this', function (t) {
t.plan(10)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
function myfunc (cb) {
t.equal(count++, i, 'calls in series')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.series(obj, [myfunc, myfunc, myfunc], function (err, snd) {
t.error(err, 'no error')
t.equal(obj, this, 'this is set')
t.deepEqual([2, 4, 6], snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('series with this without a done callback', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var count = 0
var obj = {}
function myfunc (cb) {
t.equal(count++, i, 'calls in series')
t.equal(obj, this, 'this is set')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.series(obj, [myfunc, myfunc, myfunc])
})
test('series without a done callback', function (t) {
t.plan(3)
var input = [1, 2, 3]
var i = 0
var count = 0
function myfunc (cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.series([myfunc, myfunc, myfunc])
})
test('series with an object', function (t) {
t.plan(6)
var input = [1, 2, 3]
var i = 0
var count = 0
function myfunc (cb) {
t.equal(count++, i, 'calls in series')
setImmediate(function () {
var res = input[i++]
cb(null, res * 2)
})
}
steed.series({
a: myfunc,
b: myfunc,
c: myfunc
}, function (err, snd) {
t.error(err, 'no error')
t.deepEqual({
a: 2,
b: 4,
c: 6
}, snd, 'second args contains the map')
t.equal(3, i, 'iterated over all inputs')
})
})
test('waterfall', function (t) {
t.plan(4)
steed.waterfall([ function a (cb) {
cb(null, [1])
}, function b (arg, cb) {
t.deepEqual([1], arg, 'arg for b is right')
arg.push(2)
cb(null, arg)
}, function c (arg, cb) {
t.deepEqual([1, 2], arg, 'arg for c is right')
arg.push(3)
cb(null, arg)
}], function (err, snd) {
t.error(err, 'no error')
t.deepEqual([1, 2, 3], snd, 'second args contains the last result')
})
})
test('queue', function (t) {
t.plan(4)
steed.waterfall([ function a (cb) {
cb(null, [1])
}, function b (arg, cb) {
t.deepEqual([1], arg, 'arg for b is right')
arg.push(2)
cb(null, arg)
}, function c (arg, cb) {
t.deepEqual([1, 2], arg, 'arg for c is right')
arg.push(3)
cb(null, arg)
}], function (err, snd) {
t.error(err, 'no error')
t.deepEqual([1, 2, 3], snd, 'second args contains the last result')
})
})
}
buildTest(factory)
buildTest(factory())