diff --git a/lib/index.js b/lib/index.js index 5c82eeed..a113ac60 100644 --- a/lib/index.js +++ b/lib/index.js @@ -194,20 +194,20 @@ function $p(func) { function $sequence(t, factory) { function loop(factory, idx, result) { - var e; + var obj; try { - e = factory(t, idx); // get next promise; + obj = factory(t, idx); // get next promise; } catch (e) { return $p.reject(e.message || e); } - if (!e) { + if (!obj) { // no more promises left in the sequence; return $p.resolve(result); } - if (typeof(e.then) !== 'function') { + if (typeof(obj.then) !== 'function') { return $p.reject("Promise factory returned invalid result for index " + idx); } - return e.then(function (data) { + return obj.then(function (data) { result.push(data); return loop(factory, ++idx, result); }, function (reason) {