summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2016-07-12 17:21:11 -0700
committerAlexander Early <alexander.early@gmail.com>2016-07-12 17:21:11 -0700
commit20a3026a74b957af5eb9ebd9d5afca91673017ac (patch)
treef703acf40b3ae90803436f775c898d7bf1ba4a2c
parent060c1d918dc8df8be3bd20e1f58b7c37ba20f3fd (diff)
parentbc3ca233331139bbc9b02008e67e2e5bdfd38f87 (diff)
downloadasync-20a3026a74b957af5eb9ebd9d5afca91673017ac.tar.gz
Merge branch 'master' of ssh://github.com/caolan/async
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/index.js3
-rw-r--r--lib/iterator.js48
-rw-r--r--mocha_test/iterator.js61
4 files changed, 1 insertions, 112 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9d144c2..f77d172 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,7 @@ Another big performance win has been re-implementing `queue`, `cargo`, and `prio
- The test function for `whilst`, `until`, and `during` used to be passed non-error args from the iteratee function's callback, but this led to weirdness where the first call of the test function would be passed no args. We have made it so the test function is never passed extra arguments, and only the `doWhilst`, `doUntil`, and `doDuring` functions pass iteratee callback arguments to the test function (#1217, #1224)
- The `q.tasks` array has been renamed `q._tasks` and is now implemented as a doubly linked list (DLL). Any code that used to interact with this array will need to be updated to either use the provided helpers or support DLLs (#1205).
- The timing of the `q.saturated()` callback in a `queue` has been modified to better reflect when tasks pushed to the queue will start queueing. (#724, #1078)
+- Removed `iterator` method in favour of [ES2015 iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators ) which natively supports arrays (#1237)
- Dropped support for Component, Jam, SPM, and Volo (#1175, ##176)
## Bug Fixes
diff --git a/lib/index.js b/lib/index.js
index 28b87d6..8a2c7ca 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -54,7 +54,6 @@ import filter from './filter';
import filterLimit from './filterLimit';
import filterSeries from './filterSeries';
import forever from './forever';
-import iterator from './iterator';
import log from './log';
import map from './map';
import mapLimit from './mapLimit';
@@ -129,7 +128,6 @@ export default {
filterLimit: filterLimit,
filterSeries: filterSeries,
forever: forever,
- iterator: iterator,
log: log,
map: map,
mapLimit: mapLimit,
@@ -222,7 +220,6 @@ export {
filterLimit as filterLimit,
filterSeries as filterSeries,
forever as forever,
- iterator as iterator,
log as log,
map as map,
mapLimit as mapLimit,
diff --git a/lib/iterator.js b/lib/iterator.js
deleted file mode 100644
index fafd960..0000000
--- a/lib/iterator.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Creates an iterator function which calls the next function in the `tasks`
- * array, returning a continuation to call the next one after that. It's also
- * possible to “peek” at the next iterator with `iterator.next()`.
- *
- * This function is used internally by the `async` module, but can be useful
- * when you want to manually control the flow of functions in series.
- *
- * @name iterator
- * @static
- * @memberOf module:ControlFlow
- * @method
- * @category Control Flow
- * @param {Array} tasks - An array of functions to run.
- * @returns The next function to run in the series.
- * @example
- *
- * var iterator = async.iterator([
- * function() { sys.p('one'); },
- * function() { sys.p('two'); },
- * function() { sys.p('three'); }
- * ]);
- *
- * node> var iterator2 = iterator();
- * 'one'
- * node> var iterator3 = iterator2();
- * 'two'
- * node> iterator3();
- * 'three'
- * node> var nextfn = iterator2.next();
- * node> nextfn();
- * 'three'
- */
-export default function(tasks) {
- function makeCallback(index) {
- function fn() {
- if (tasks.length) {
- tasks[index].apply(null, arguments);
- }
- return fn.next();
- }
- fn.next = function() {
- return (index < tasks.length - 1) ? makeCallback(index + 1) : null;
- };
- return fn;
- }
- return makeCallback(0);
-}
diff --git a/mocha_test/iterator.js b/mocha_test/iterator.js
deleted file mode 100644
index 71c477c..0000000
--- a/mocha_test/iterator.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var async = require('../lib');
-var expect = require('chai').expect;
-
-describe('iterator', function() {
-
- it('iterator', function(done) {
- var call_order = [];
- var iterator = async.iterator([
- function(){call_order.push(1);},
- function(arg1){
- expect(arg1).to.equal('arg1');
- call_order.push(2);
- },
- function(arg1, arg2){
- expect(arg1).to.equal('arg1');
- expect(arg2).to.equal('arg2');
- call_order.push(3);
- }
- ]);
- iterator();
- expect(call_order).to.eql([1]);
- var iterator2 = iterator();
- expect(call_order).to.eql([1,1]);
- var iterator3 = iterator2('arg1');
- expect(call_order).to.eql([1,1,2]);
- var iterator4 = iterator3('arg1', 'arg2');
- expect(call_order).to.eql([1,1,2,3]);
- expect(iterator4).to.equal(null);
- done();
- });
-
- it('iterator empty array', function(done) {
- var iterator = async.iterator([]);
- expect(iterator()).to.equal(null);
- expect(iterator.next()).to.equal(null);
- done();
- });
-
- it('iterator.next', function(done) {
- var call_order = [];
- var iterator = async.iterator([
- function(){call_order.push(1);},
- function(arg1){
- expect(arg1).to.equal('arg1');
- call_order.push(2);
- },
- function(arg1, arg2){
- expect(arg1).to.equal('arg1');
- expect(arg2).to.equal('arg2');
- call_order.push(3);
- }
- ]);
- var fn = iterator.next();
- var iterator2 = fn('arg1');
- expect(call_order).to.eql([2]);
- iterator2('arg1','arg2');
- expect(call_order).to.eql([2,3]);
- expect(iterator2.next()).to.equal(null);
- done();
- });
-});