Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Commit

Permalink
Fixing retry tests and removing Function#bind
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Jan 14, 2015
1 parent b90653a commit 9fd10f9
Show file tree
Hide file tree
Showing 32 changed files with 266 additions and 162 deletions.
29 changes: 27 additions & 2 deletions dist/rx.aggregates.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,37 @@
* @returns {Observable} An observable sequence containing a single element with the final accumulator value.
*/
observableProto.reduce = function (accumulator) {
var seed, hasSeed;
var hasSeed = false, seed, source = this;
if (arguments.length === 2) {
hasSeed = true;
seed = arguments[1];
}
return hasSeed ? this.scan(seed, accumulator).startWith(seed).finalValue() : this.scan(accumulator).finalValue();
return new AnonymousObservable(function (o) {
var hasAccumulation, accumulation, hasValue;
return source.subscribe (
function (x) {
!hasValue && (hasValue = true);
try {
if (hasAccumulation) {
accumulation = accumulator(accumulation, x);
} else {
accumulation = hasSeed ? accumulator(seed, x) : x;
hasAccumulation = true;
}
} catch (e) {
o.onError(e);
return;
}
},
function (e) { o.onError(e); },
function () {
hasValue && o.onNext(accumulation);
!hasValue && hasSeed && o.onNext(seed);
!hasValue && !hasSeed && o.onError(new Error(sequenceContainsNoElements));
o.onCompleted();
}
);
}, source);
};

/**
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.aggregates.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.aggregates.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9fd10f9

Please sign in to comment.