savoy
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "savoy", | ||
"main": "savoy.min.js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"homepage": "https://github.com/yuanqing/savoy", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "savoy", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Higher-order functions (synchronous and asynchronous each/map/filter/fold) and functions for flow control (parallel/series/waterfall) in under 1 KB.", | ||
@@ -5,0 +5,0 @@ "author": "Lim Yuan Qing", |
@@ -6,3 +6,3 @@ # Savoy.js [![npm Version](http://img.shields.io/npm/v/savoy.svg?style=flat)](https://www.npmjs.org/package/savoy) [![Build Status](https://img.shields.io/travis/yuanqing/savoy.svg?style=flat)](https://travis-ci.org/yuanqing/savoy) [![Coverage Status](https://img.shields.io/coveralls/yuanqing/savoy.svg?style=flat)](https://coveralls.io/r/yuanqing/savoy) | ||
- API is similar to that of the [async](https://github.com/caolan/async) library | ||
- 2.2 KB [minified](https://github.com/yuanqing/savoy/blob/master/savoy.min.js), or about 0.9 KB minified and gzipped | ||
- 2.5 KB [minified](https://github.com/yuanqing/savoy/blob/master/savoy.min.js), or about 0.9 KB minified and gzipped | ||
- [Legible tests](https://github.com/yuanqing/savoy/blob/master/test), with [100% coverage](https://coveralls.io/r/yuanqing/savoy) | ||
@@ -69,4 +69,6 @@ | ||
- `fn` is called in *parallel* over each item in `collection`. | ||
- Invoke the `cb` callback in `fn` to signal the end of `fn`. (Note that `cb` is the *first* argument of `fn`.) | ||
- The asynchronous function `fn` is called in *parallel* over each item in `collection`. | ||
- Invoke the `cb` callback in `fn` to signal the end of each iteration of `fn`. | ||
- The signature of the `cb` callback is `cb(err)`. If `err` is truthy, the `done` callback is called exactly once with the `err`. | ||
- When `fn` has completed execution over every item in the `collection`, the `done` callback is called exactly once with a falsy `err`. | ||
@@ -104,5 +106,10 @@ ### map | ||
- `fn` is called in *parallel* over each item in `collection`. | ||
- `result` will be of the same type as `collection`, ie. if `collection` was an Object, `result` will also be an Object. | ||
- Items in `result` will be in the same order as they were in `collection`. | ||
- The asynchronous function `fn` is called in *parallel* over each item in `collection`. | ||
- Invoke the `cb` callback in `fn` to signal the end of each iteration of `fn`. The signature of the `cb` callback is `cb(err, mapVal)`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `mapVal` — This is accumulated in the `result` argument of the `done` callback. | ||
- When `fn` has completed execution over every item in the `collection`, the `done` callback is called exactly once with a falsy `err` and the `result` of the map. | ||
- Note that if `collection` is an Object: | ||
1. `result` will also be an Object. | ||
2. Items in `result` may *not* be in the same order as their corresponding items in the original `collection`. | ||
@@ -140,5 +147,10 @@ ### filter | ||
- `fn` is called in *parallel* over each item in `collection`. | ||
- `result` will be of the same type as `collection`, ie. if `collection` was an Object, `result` will also be an Object. | ||
- Items in `result` will be in the same relative order as they were in `collection`. | ||
- The asynchronous function `fn` is called in *parallel* over each item in `collection`. | ||
- Invoke the `cb` callback in `fn` to signal the end of each iteration of `fn`. The signature of the `cb` callback is `cb(err, predicate)`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `predicate` — If truthy, the current item is added to the `result` argument of the `done` callback. | ||
- When `fn` has completed execution over every item in the `collection`, the `done` callback is called exactly once with a falsy `err` and the `result` of the filter. | ||
- Note that if `collection` is an Object: | ||
1. `result` will also be an Object. | ||
2. Items in `result` may *not* be in the same relative order as they were in `collection`. | ||
@@ -176,7 +188,11 @@ ### fold | ||
- `fn` is called in *series* for each item in `collection`. | ||
- The asynchronous function `fn` is called in *series* over each item in `collection`. | ||
- Invoke the `cb` callback in `fn` to signal the end of each iteration of `fn`. The signature of the `cb` callback is `cb(err, foldVal)`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `foldVal` — This is the value for `acc` that is passed to the next iteration of `fn`. | ||
- When `fn` has completed execution over every item in the `collection`, the `done` callback is called exactly once with a falsy `err` and the `result` of the fold. | ||
### parallel | ||
**savoy.parallel(fns, done)** | ||
**savoy.parallel(fns [, done])** | ||
@@ -201,7 +217,10 @@ ```js | ||
- Each function in `fns` is called in *parallel*. | ||
- The second argument passed to `cb` by each function is collected in `result`. | ||
- Invoke the `cb` callback in each function to signal the end of the function. The signature of the `cb` callback is `cb(err, val)`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `val` — This is accumulated in the `result` argument of the `done` callback. | ||
- When every function in `fns` has completed execution, the `done` callback is called exactly once with a falsy `err` and the `result` of each function. | ||
### series | ||
**savoy.series(fns, done)** | ||
**savoy.series(fns [, done])** | ||
@@ -226,7 +245,10 @@ ```js | ||
- Each function in `fns` is called in *series*. | ||
- The second argument passed to `cb` by each function is collected in `result`. | ||
- Invoke the `cb` callback in each function to signal the end of the function. The signature of the `cb` callback is `cb(err, val)`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `val` — This is accumulated in the `result` argument of the `done` callback. | ||
- When the entire series of functions has completed execution, the `done` callback is called exactly once with a falsy `err` and the `result` of each function. | ||
### waterfall | ||
**savoy.waterfall(fns, done)** | ||
**savoy.waterfall(fns [, done])** | ||
@@ -243,15 +265,18 @@ ```js | ||
}, | ||
function(cb, args) { | ||
console.log(args); | ||
function(cb, arg) { | ||
console.log(arg); | ||
//=> 'c' | ||
cb(null, 'd'); | ||
cb(null, 'd', 'e'); | ||
} | ||
], function(err, arg) { | ||
console.log(err, arg); | ||
//=> null, 'd' | ||
], function(err, arg1, arg2) { | ||
console.log(err, arg1, arg2); | ||
//=> null, 'd', 'e' | ||
}); | ||
``` | ||
- Each function in `fns` is called in *parallel*. | ||
- Arguments (other than the first argument) passed to `cb` by each function in `fns` will be passed on to the next function in `fns`. | ||
- Each function in `fns` is called in *series*. | ||
- Invoke the `cb` callback in each function to signal the end of the function. The signature of the `cb` callback is `cb(err [, arg1, arg2, ...])`: | ||
1. `err` — If truthy, the `done` callback is called exactly once with the `err`. | ||
2. `arg1, arg2, ...` — Arguments that are passed on to the next function in `fns`. | ||
- When the entire series of functions has completed execution, the `done` callback is called exactly once with a falsy `err` and arguments from the last function in `fns`. | ||
@@ -258,0 +283,0 @@ ## Installation |
136
savoy.js
@@ -24,32 +24,24 @@ (function(exports) { | ||
var asyncSeriesEach = function(collection, fn, cb) { | ||
var syncParallelEach = function(collection, fn) { | ||
var keys = isArr(collection) ? false : objKeys(collection); | ||
var len = (keys || collection).length; | ||
var i = 0; | ||
var i = -1; | ||
var key; | ||
var cbWrap = function(err) { | ||
if (err) { | ||
cb(err); | ||
return; | ||
if (keys) { | ||
while (++i < len) { | ||
key = keys[i]; | ||
if (fn(collection[key], key, collection) === false) { | ||
break; | ||
} | ||
} | ||
if (++i === len) { | ||
cb(null); | ||
return; | ||
} else { | ||
while (++i < len) { | ||
if (fn(collection[i], i, collection) === false) { | ||
break; | ||
} | ||
} | ||
call(); | ||
}; | ||
var call = keys ? function() { | ||
key = keys[i]; | ||
fn(cbWrap, collection[key], key, collection); | ||
} : function() { | ||
fn(cbWrap, collection[i], i, collection); | ||
}; | ||
if (!len) { | ||
cb(null); | ||
return; | ||
} | ||
call(); | ||
}; | ||
var asyncParallelEach = function(collection, fn, cb) { | ||
var asyncParallelEach = function(collection, fn, done) { | ||
var keys = isArr(collection) ? false : objKeys(collection); | ||
@@ -60,14 +52,14 @@ var len = (keys || collection).length; | ||
var count = 0; | ||
var cbWrap = function(err) { | ||
var cb = function(err) { | ||
if (err) { | ||
cb(err); | ||
cb = noop; | ||
done(err); | ||
done = noop; | ||
return; | ||
} | ||
if (++count === len) { | ||
cb(null); | ||
done(null); | ||
} | ||
}; | ||
if (!len) { | ||
cb(null); | ||
done(null); | ||
return; | ||
@@ -78,7 +70,7 @@ } | ||
key = keys[i]; | ||
fn(cbWrap, collection[key], key, collection); | ||
fn(cb, collection[key], key, collection); | ||
} | ||
} else { | ||
while (++i < len) { | ||
fn(cbWrap, collection[i], i, collection); | ||
fn(cb, collection[i], i, collection); | ||
} | ||
@@ -88,21 +80,29 @@ } | ||
var syncParallelEach = function(collection, fn) { | ||
var asyncSeriesEach = function(collection, fn, done) { | ||
var keys = isArr(collection) ? false : objKeys(collection); | ||
var len = (keys || collection).length; | ||
var i = -1; | ||
var i = 0; | ||
var key; | ||
if (keys) { | ||
while (++i < len) { | ||
key = keys[i]; | ||
if (fn(collection[key], key, collection) === false) { | ||
break; | ||
} | ||
var cb = function(err) { | ||
if (err) { | ||
done(err); | ||
return; | ||
} | ||
} else { | ||
while (++i < len) { | ||
if (fn(collection[i], i, collection) === false) { | ||
break; | ||
} | ||
if (++i === len) { | ||
done(null); | ||
return; | ||
} | ||
call(); | ||
}; | ||
var call = keys ? function() { | ||
key = keys[i]; | ||
fn(cb, collection[key], key, collection); | ||
} : function() { | ||
fn(cb, collection[i], i, collection); | ||
}; | ||
if (!len) { | ||
done(null); | ||
return; | ||
} | ||
call(); | ||
}; | ||
@@ -118,3 +118,3 @@ | ||
var asyncMap = function(collection, fn, cb) { | ||
var asyncMap = function(collection, fn, done) { | ||
var result = isArr(collection) ? [] : {}; | ||
@@ -127,3 +127,3 @@ asyncParallelEach(collection, function(cb, val, key, collection) { | ||
}, function(err) { | ||
cb(err, result); | ||
done(err, result); | ||
}); | ||
@@ -152,3 +152,3 @@ }; | ||
var asyncFilter = function(collection, fn, cb) { | ||
var asyncFilter = function(collection, fn, done) { | ||
var result; | ||
@@ -165,3 +165,3 @@ if (isArr(collection)) { | ||
}, function(err) { | ||
cb(err, syncMap(result.sort(function(a, b) { | ||
done(err, syncMap(result.sort(function(a, b) { | ||
return a.i - b.i; | ||
@@ -182,3 +182,3 @@ }), function(item) { | ||
}, function(err) { | ||
cb(err, result); | ||
done(err, result); | ||
}); | ||
@@ -195,3 +195,3 @@ } | ||
var asyncFold = function(collection, acc, fn, cb) { | ||
var asyncFold = function(collection, acc, fn, done) { | ||
asyncSeriesEach(collection, function(cb, val, key, collection) { | ||
@@ -203,23 +203,23 @@ fn(function(err, foldVal) { | ||
}, function(err) { | ||
cb(err, acc); | ||
done(err, acc); | ||
}); | ||
}; | ||
exports.each = function(collection, fn, cb) { | ||
return cb ? asyncParallelEach(collection, fn, cb) : syncParallelEach(collection, fn); | ||
exports.each = function(collection, fn, done) { | ||
return done ? asyncParallelEach(collection, fn, done) : syncParallelEach(collection, fn); | ||
}; | ||
exports.map = function(collection, fn, cb) { | ||
return cb ? asyncMap(collection, fn, cb) : syncMap(collection, fn); | ||
exports.map = function(collection, fn, done) { | ||
return done ? asyncMap(collection, fn, done) : syncMap(collection, fn); | ||
}; | ||
exports.filter = function(collection, fn, cb) { | ||
return cb ? asyncFilter(collection, fn, cb) : syncFilter(collection, fn); | ||
exports.filter = function(collection, fn, done) { | ||
return done ? asyncFilter(collection, fn, done) : syncFilter(collection, fn); | ||
}; | ||
exports.fold = function(collection, acc, fn, cb) { | ||
return cb ? asyncFold(collection, acc, fn, cb) : syncFold(collection, acc, fn); | ||
exports.fold = function(collection, acc, fn, done) { | ||
return done ? asyncFold(collection, acc, fn, done) : syncFold(collection, acc, fn); | ||
}; | ||
exports.parallel = function(fns, cb) { | ||
exports.parallel = function(fns, done) { | ||
exports.map(fns, function(cb, fn) { | ||
@@ -230,7 +230,7 @@ fn(function(err, val) { | ||
}, function(err, result) { | ||
(cb || noop)(err, result); | ||
(done || noop)(err, result); | ||
}); | ||
}; | ||
exports.series = function(fns, cb) { | ||
exports.series = function(fns, done) { | ||
var result = isArr(fns) ? [] : {}; | ||
@@ -243,27 +243,27 @@ asyncSeriesEach(fns, function(cb, fn, key) { | ||
}, function(err) { | ||
(cb || noop)(err, result); | ||
(done || noop)(err, result); | ||
}); | ||
}; | ||
exports.waterfall = function(fns, cb) { | ||
exports.waterfall = function(fns, done) { | ||
var keys = isArr(fns) ? false : objKeys(fns); | ||
var len = (keys || fns).length; | ||
var i = -1; | ||
var cbWrap = function(err) { | ||
var cb = function(err) { | ||
if (err) { | ||
cb(err); | ||
done(err); | ||
return; | ||
} | ||
if (++i === len) { | ||
cb.apply(null, arguments); | ||
done.apply(null, arguments); | ||
return; | ||
} | ||
var args = arrSlice.call(arguments); | ||
args[0] = cbWrap; | ||
args[0] = cb; | ||
(keys ? fns[keys[i]] : fns[i]).apply(null, args); | ||
}; | ||
cb = cb || noop; | ||
cbWrap(); | ||
done = done || noop; | ||
cb(); | ||
}; | ||
})(typeof exports == 'undefined' ? this.savoy : exports); |
@@ -1,1 +0,1 @@ | ||
(function(n){var r=function(){};var t=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"};var i=Object.keys||function(n){var r=[];var t;for(t in n){if(n.hasOwnProperty(t)){r.push(t)}}return r};var f=Array.prototype.slice;var u=function(n,r,f){var u=t(n)?false:i(n);var a=(u||n).length;var e=0;var o;var c=function(n){if(n){f(n);return}if(++e===a){f(null);return}l()};var l=u?function(){o=u[e];r(c,n[o],o,n)}:function(){r(c,n[e],e,n)};if(!a){f(null);return}l()};var a=function(n,f,u){var a=t(n)?false:i(n);var e=(a||n).length;var o=-1;var c;var l=0;var v=function(n){if(n){u(n);u=r;return}if(++l===e){u(null)}};if(!e){u(null);return}if(a){while(++o<e){c=a[o];f(v,n[c],c,n)}}else{while(++o<e){f(v,n[o],o,n)}}};var e=function(n,r){var f=t(n)?false:i(n);var u=(f||n).length;var a=-1;var e;if(f){while(++a<u){e=f[a];if(r(n[e],e,n)===false){break}}}else{while(++a<u){if(r(n[a],a,n)===false){break}}}};var o=function(n,r){var i=t(n)?[]:{};e(n,function(n,t,f){i[t]=r(n,t,f)});return i};var c=function(n,r,i){var f=t(n)?[]:{};a(n,function(n,t,i,u){r(function(r,t){f[i]=t;n(r)},t,i,u)},function(n){i(n,f)})};var l=function(n,r){var i;if(t(n)){i=[];e(n,function(n,t,f){if(r(n,t,f)){i.push(n)}})}else{i={};e(n,function(n,t,f){if(r(n,t,f)){i[t]=n}})}return i};var v=function(n,r,i){var f;if(t(n)){f=[];a(n,function(n,t,i,u){r(function(r,u){if(u){f.push({i:i,val:t})}n(r)},t,i,u)},function(n){i(n,o(f.sort(function(n,r){return n.i-r.i}),function(n){return n.val}))})}else{f={};a(n,function(n,t,i,u){r(function(r,u){if(u){f[i]=t}n(r)},t,i,u)},function(n){i(n,f)})}};var s=function(n,r,t){e(n,function(n,i,f){r=t(r,n,i,f)});return r};var p=function(n,r,t,i){u(n,function(n,i,f,u){t(function(t,i){r=i;n(t)},r,i,f,u)},function(n){i(n,r)})};n.each=function(n,r,t){return t?a(n,r,t):e(n,r)};n.map=function(n,r,t){return t?c(n,r,t):o(n,r)};n.filter=function(n,r,t){return t?v(n,r,t):l(n,r)};n.fold=function(n,r,t,i){return i?p(n,r,t,i):s(n,r,t)};n.parallel=function(t,i){n.map(t,function(n,r){r(function(r,t){n(r,t)})},function(n,t){(i||r)(n,t)})};n.series=function(n,i){var f=t(n)?[]:{};u(n,function(n,r,t){r(function(r,i){f[t]=i;n(r)})},function(n){(i||r)(n,f)})};n.waterfall=function(n,u){var a=t(n)?false:i(n);var e=(a||n).length;var o=-1;var c=function(r){if(r){u(r);return}if(++o===e){u.apply(null,arguments);return}var t=f.call(arguments);t[0]=c;(a?n[a[o]]:n[o]).apply(null,t)};u=u||r;c()}})(typeof exports=="undefined"?this.savoy:exports); | ||
(function(n){var r=function(){};var t=Array.isArray||function(n){return Object.prototype.toString.call(n)==="[object Array]"};var i=Object.keys||function(n){var r=[];var t;for(t in n){if(n.hasOwnProperty(t)){r.push(t)}}return r};var f=Array.prototype.slice;var u=function(n,r){var f=t(n)?false:i(n);var u=(f||n).length;var a=-1;var e;if(f){while(++a<u){e=f[a];if(r(n[e],e,n)===false){break}}}else{while(++a<u){if(r(n[a],a,n)===false){break}}}};var a=function(n,f,u){var a=t(n)?false:i(n);var e=(a||n).length;var o=-1;var c;var l=0;var v=function(n){if(n){u(n);u=r;return}if(++l===e){u(null)}};if(!e){u(null);return}if(a){while(++o<e){c=a[o];f(v,n[c],c,n)}}else{while(++o<e){f(v,n[o],o,n)}}};var e=function(n,r,f){var u=t(n)?false:i(n);var a=(u||n).length;var e=0;var o;var c=function(n){if(n){f(n);return}if(++e===a){f(null);return}l()};var l=u?function(){o=u[e];r(c,n[o],o,n)}:function(){r(c,n[e],e,n)};if(!a){f(null);return}l()};var o=function(n,r){var i=t(n)?[]:{};u(n,function(n,t,f){i[t]=r(n,t,f)});return i};var c=function(n,r,i){var f=t(n)?[]:{};a(n,function(n,t,i,u){r(function(r,t){f[i]=t;n(r)},t,i,u)},function(n){i(n,f)})};var l=function(n,r){var i;if(t(n)){i=[];u(n,function(n,t,f){if(r(n,t,f)){i.push(n)}})}else{i={};u(n,function(n,t,f){if(r(n,t,f)){i[t]=n}})}return i};var v=function(n,r,i){var f;if(t(n)){f=[];a(n,function(n,t,i,u){r(function(r,u){if(u){f.push({i:i,val:t})}n(r)},t,i,u)},function(n){i(n,o(f.sort(function(n,r){return n.i-r.i}),function(n){return n.val}))})}else{f={};a(n,function(n,t,i,u){r(function(r,u){if(u){f[i]=t}n(r)},t,i,u)},function(n){i(n,f)})}};var s=function(n,r,t){u(n,function(n,i,f){r=t(r,n,i,f)});return r};var p=function(n,r,t,i){e(n,function(n,i,f,u){t(function(t,i){r=i;n(t)},r,i,f,u)},function(n){i(n,r)})};n.each=function(n,r,t){return t?a(n,r,t):u(n,r)};n.map=function(n,r,t){return t?c(n,r,t):o(n,r)};n.filter=function(n,r,t){return t?v(n,r,t):l(n,r)};n.fold=function(n,r,t,i){return i?p(n,r,t,i):s(n,r,t)};n.parallel=function(t,i){n.map(t,function(n,r){r(function(r,t){n(r,t)})},function(n,t){(i||r)(n,t)})};n.series=function(n,i){var f=t(n)?[]:{};e(n,function(n,r,t){r(function(r,i){f[t]=i;n(r)})},function(n){(i||r)(n,f)})};n.waterfall=function(n,u){var a=t(n)?false:i(n);var e=(a||n).length;var o=-1;var c=function(r){if(r){u(r);return}if(++o===e){u.apply(null,arguments);return}var t=f.call(arguments);t[0]=c;(a?n[a[o]]:n[o]).apply(null,t)};u=u||r;c()}})(typeof exports=="undefined"?this.savoy:exports); |
@@ -136,5 +136,5 @@ /* globals jasmine, describe, it, expect */ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var arr = [1, 2, 3]; | ||
@@ -146,6 +146,6 @@ var duration = [20, 10, 30]; | ||
}, duration[i]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(arr).toEqual([1, 2, 3]); | ||
@@ -191,5 +191,5 @@ jasmine.clock().uninstall(); | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var obj = { a: 1, b: 2, c: 3 }; | ||
@@ -201,6 +201,6 @@ var duration = { a: 20, b: 10, c: 30 }; | ||
}, duration[key]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(obj).toEqual({ a: 1, b: 2, c: 3 }); | ||
@@ -207,0 +207,0 @@ jasmine.clock().uninstall(); |
@@ -118,5 +118,5 @@ /* globals jasmine, describe, it, expect */ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var arr = [1, 2, 3]; | ||
@@ -128,6 +128,6 @@ var duration = [20, 10, 30]; | ||
}, duration[i]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(arr).toEqual([1, 2, 3]); | ||
@@ -179,5 +179,5 @@ jasmine.clock().uninstall(); | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var obj = { a: 1, b: 2, c: 3 }; | ||
@@ -189,6 +189,6 @@ var duration = { a: 20, b: 10, c: 30 }; | ||
}, duration[key]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(obj).toEqual({ a: 1, b: 2, c: 3 }); | ||
@@ -195,0 +195,0 @@ jasmine.clock().uninstall(); |
@@ -118,5 +118,5 @@ /* globals jasmine, describe, it, expect */ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var arr = [1, 2, 3]; | ||
@@ -127,6 +127,6 @@ fold(arr, 100, function(cb, acc, val) { | ||
}, 0); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(1); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(1); | ||
expect(arr).toEqual([1, 2, 3]); | ||
@@ -178,5 +178,5 @@ jasmine.clock().uninstall(); | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var obj = { a: 1, b: 2, c: 3 }; | ||
@@ -187,6 +187,6 @@ fold(obj, 100, function(cb, acc, val) { | ||
}, 0); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(1); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(1); | ||
expect(obj).toEqual({ a: 1, b: 2, c: 3 }); | ||
@@ -193,0 +193,0 @@ jasmine.clock().uninstall(); |
@@ -118,5 +118,5 @@ /* globals jasmine, describe, it, expect */ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var arr = [1, 2, 3]; | ||
@@ -128,6 +128,6 @@ var duration = [20, 10, 30]; | ||
}, duration[i]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(arr).toEqual([1, 2, 3]); | ||
@@ -179,5 +179,5 @@ jasmine.clock().uninstall(); | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
var obj = { a: 1, b: 2, c: 3 }; | ||
@@ -189,6 +189,6 @@ var duration = { a: 20, b: 10, c: 30 }; | ||
}, duration[key]); | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toEqual(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toEqual(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
expect(obj).toEqual({ a: 1, b: 2, c: 3 }); | ||
@@ -195,0 +195,0 @@ jasmine.clock().uninstall(); |
@@ -18,3 +18,3 @@ /* globals jasmine, describe, it, expect */ | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -47,3 +47,3 @@ var calls = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var calls = []; | ||
@@ -77,5 +77,5 @@ parallel([ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
parallel([ | ||
@@ -97,6 +97,6 @@ function(cb) { | ||
} | ||
], cb); | ||
], done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
jasmine.clock().uninstall(); | ||
@@ -117,3 +117,3 @@ }); | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -146,3 +146,3 @@ var calls = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var calls = []; | ||
@@ -176,5 +176,5 @@ parallel({ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
parallel({ | ||
@@ -196,6 +196,6 @@ a: function(cb) { | ||
} | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(2); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(2); | ||
jasmine.clock().uninstall(); | ||
@@ -202,0 +202,0 @@ }); |
@@ -18,3 +18,3 @@ /* globals jasmine, describe, it, expect */ | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -47,3 +47,3 @@ var calls = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var calls = []; | ||
@@ -77,5 +77,5 @@ series([ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
series([ | ||
@@ -97,6 +97,6 @@ function(cb) { | ||
} | ||
], cb); | ||
], done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(1); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(1); | ||
jasmine.clock().uninstall(); | ||
@@ -117,3 +117,3 @@ }); | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -146,3 +146,3 @@ var calls = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var calls = []; | ||
@@ -176,5 +176,5 @@ series({ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
series({ | ||
@@ -196,6 +196,6 @@ a: function(cb) { | ||
} | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.argsFor(0)[0]).toEqual(1); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.argsFor(0)[0]).toEqual(1); | ||
jasmine.clock().uninstall(); | ||
@@ -202,0 +202,0 @@ }); |
@@ -18,3 +18,3 @@ /* globals jasmine, describe, it, expect */ | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -47,3 +47,3 @@ var args = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var args = []; | ||
@@ -77,5 +77,5 @@ waterfall([ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
waterfall([ | ||
@@ -97,6 +97,6 @@ function(cb) { | ||
} | ||
], cb); | ||
], done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.allArgs()).toEqual([[1]]); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.allArgs()).toEqual([[1]]); | ||
jasmine.clock().uninstall(); | ||
@@ -117,3 +117,3 @@ }); | ||
it('no `cb`, iterates through', function() { | ||
it('no `done`, iterates through', function() { | ||
jasmine.clock().install(); | ||
@@ -146,3 +146,3 @@ var args = []; | ||
it('with `cb`, iterates through', function(done) { | ||
it('with `done`, iterates through', function(done) { | ||
var args = []; | ||
@@ -176,5 +176,5 @@ waterfall({ | ||
it('on error, calls `cb` exactly once', function() { | ||
it('on error, calls `done` exactly once', function() { | ||
jasmine.clock().install(); | ||
var cb = jasmine.createSpy(); | ||
var done = jasmine.createSpy(); | ||
waterfall({ | ||
@@ -196,6 +196,6 @@ a: function(cb) { | ||
} | ||
}, cb); | ||
}, done); | ||
jasmine.clock().tick(1000); | ||
expect(cb.calls.count()).toBe(1); | ||
expect(cb.calls.allArgs()).toEqual([[1]]); | ||
expect(done.calls.count()).toBe(1); | ||
expect(done.calls.allArgs()).toEqual([[1]]); | ||
jasmine.clock().uninstall(); | ||
@@ -202,0 +202,0 @@ }); |
58298
313