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

Commit 32ee552

Browse files
Removing all arguments issues with Issue #519
1 parent fe00014 commit 32ee552

52 files changed

Lines changed: 517 additions & 395 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

dist/rx.all.compat.js

Lines changed: 77 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -494,13 +494,8 @@
494494
return result;
495495
}
496496

497-
var slice = Array.prototype.slice;
498-
function argsOrArray(args, idx) {
499-
return args.length === 1 && Array.isArray(args[idx]) ?
500-
args[idx] :
501-
slice.call(args);
502-
}
503-
var hasProp = {}.hasOwnProperty;
497+
var hasProp = {}.hasOwnProperty,
498+
slice = Array.prototype.slice;
504499

505500
var inherits = this.inherits = Rx.internals.inherits = function (child, parent) {
506501
function __() { this.constructor = child; }
@@ -509,9 +504,9 @@
509504
};
510505

511506
var addProperties = Rx.internals.addProperties = function (obj) {
512-
var sources = slice.call(arguments, 1);
513-
for (var i = 0, len = sources.length; i < len; i++) {
514-
var source = sources[i];
507+
for(var sources = [], i = 1, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }
508+
for (var idx = 0, ln = sources.length; idx < ln; idx++) {
509+
var source = sources[idx];
515510
for (var prop in source) {
516511
obj[prop] = source[prop];
517512
}
@@ -2816,7 +2811,8 @@
28162811
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
28172812
*/
28182813
Observable.of = function () {
2819-
return observableOf(null, arguments);
2814+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
2815+
return observableOf(null, args);
28202816
};
28212817

28222818
/**
@@ -2825,7 +2821,8 @@
28252821
* @returns {Observable} The observable sequence whose elements are pulled from the given arguments.
28262822
*/
28272823
Observable.ofWithScheduler = function (scheduler) {
2828-
return observableOf(scheduler, slice.call(arguments, 1));
2824+
for(var args = [], i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
2825+
return observableOf(scheduler, args);
28292826
};
28302827

28312828
/**
@@ -2847,12 +2844,12 @@
28472844
Observable.pairs = function (obj, scheduler) {
28482845
scheduler || (scheduler = Rx.Scheduler.currentThread);
28492846
return new AnonymousObservable(function (observer) {
2850-
var idx = 0, keys = Object.keys(obj), len = keys.length;
2851-
return scheduler.scheduleRecursive(function (self) {
2847+
var keys = Object.keys(obj), len = keys.length;
2848+
return scheduler.scheduleRecursiveWithState(0, function (idx, self) {
28522849
if (idx < len) {
2853-
var key = keys[idx++];
2850+
var key = keys[idx];
28542851
observer.onNext([key, obj[key]]);
2855-
self();
2852+
self(idx + 1);
28562853
} else {
28572854
observer.onCompleted();
28582855
}
@@ -3043,8 +3040,13 @@
30433040
* @returns {Observable} An observable sequence that surfaces any of the given sequences, whichever reacted first.
30443041
*/
30453042
Observable.amb = function () {
3046-
var acc = observableNever(),
3047-
items = argsOrArray(arguments, 0);
3043+
var acc = observableNever(), items = [];
3044+
if (Array.isArray(arguments[0])) {
3045+
items = arguments[0];
3046+
} else {
3047+
for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }
3048+
}
3049+
30483050
function func(previous, current) {
30493051
return previous.amb(current);
30503052
}
@@ -3104,16 +3106,14 @@
31043106
* @param {Array | Arguments} args Arguments or an array to use as the next sequence if an error occurs.
31053107
* @returns {Observable} An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.
31063108
*/
3107-
var observableCatch = Observable.catchError = Observable['catch'] = function () {
3108-
return enumerableOf(argsOrArray(arguments, 0)).catchError();
3109-
};
3110-
3111-
/**
3112-
* @deprecated use #catch or #catchError instead.
3113-
*/
3114-
Observable.catchException = function () {
3115-
//deprecate('catchException', 'catch or catchError');
3116-
return observableCatch.apply(null, arguments);
3109+
var observableCatch = Observable.catchError = Observable['catch'] = Observable.catchException = function () {
3110+
var items = [];
3111+
if (Array.isArray(arguments[0])) {
3112+
items = arguments[0];
3113+
} else {
3114+
for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }
3115+
}
3116+
return enumerableOf(items).catchError();
31173117
};
31183118

31193119
/**
@@ -3144,7 +3144,8 @@
31443144
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
31453145
*/
31463146
var combineLatest = Observable.combineLatest = function () {
3147-
var args = slice.call(arguments), resultSelector = args.pop();
3147+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3148+
var resultSelector = args.pop();
31483149

31493150
if (Array.isArray(args[0])) {
31503151
args = args[0];
@@ -3217,7 +3218,13 @@
32173218
* @returns {Observable} An observable sequence that contains the elements of each given sequence, in sequential order.
32183219
*/
32193220
var observableConcat = Observable.concat = function () {
3220-
return enumerableOf(argsOrArray(arguments, 0)).concat();
3221+
var items = [];
3222+
if (Array.isArray(arguments[0])) {
3223+
items = arguments[0];
3224+
} else {
3225+
for(var i = 0, len = arguments.length; i < len; i++) { items.push(arguments[i]); }
3226+
}
3227+
return enumerableOf(items).concat();
32213228
};
32223229

32233230
/**
@@ -3282,16 +3289,16 @@
32823289
* @returns {Observable} The observable sequence that merges the elements of the observable sequences.
32833290
*/
32843291
var observableMerge = Observable.merge = function () {
3285-
var scheduler, sources;
3292+
var scheduler, sources = [], i, len = arguments.length;
32863293
if (!arguments[0]) {
32873294
scheduler = immediateScheduler;
3288-
sources = slice.call(arguments, 1);
3295+
for(i = 1; i < len; i++) { sources.push(arguments[i]); }
32893296
} else if (isScheduler(arguments[0])) {
32903297
scheduler = arguments[0];
3291-
sources = slice.call(arguments, 1);
3298+
for(i = 1; i < len; i++) { sources.push(arguments[i]); }
32923299
} else {
32933300
scheduler = immediateScheduler;
3294-
sources = slice.call(arguments, 0);
3301+
for(i = 0; i < len; i++) { sources.push(arguments[i]); }
32953302
}
32963303
if (Array.isArray(sources[0])) {
32973304
sources = sources[0];
@@ -3357,7 +3364,12 @@
33573364
* @returns {Observable} An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.
33583365
*/
33593366
var onErrorResumeNext = Observable.onErrorResumeNext = function () {
3360-
var sources = argsOrArray(arguments, 0);
3367+
var sources = [];
3368+
if (Array.isArray(arguments[0])) {
3369+
sources = arguments[0];
3370+
} else {
3371+
for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }
3372+
}
33613373
return new AnonymousObservable(function (observer) {
33623374
var pos = 0, subscription = new SerialDisposable(),
33633375
cancelable = immediateScheduler.scheduleRecursive(function (self) {
@@ -3470,9 +3482,8 @@
34703482
* @returns {Observable} An observable sequence containing the result of combining elements of the sources using the specified result selector function.
34713483
*/
34723484
observableProto.withLatestFrom = function () {
3473-
var source = this;
3474-
var args = slice.call(arguments);
3475-
var resultSelector = args.pop();
3485+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
3486+
var resultSelector = args.pop(), source = this;
34763487

34773488
if (typeof source === 'undefined') {
34783489
throw new Error('Source observable not found for withLatestFrom().');
@@ -3628,7 +3639,12 @@
36283639
* @returns {Observable} An observable sequence containing lists of elements at corresponding indexes.
36293640
*/
36303641
Observable.zipArray = function () {
3631-
var sources = argsOrArray(arguments, 0);
3642+
var sources = [];
3643+
if (Array.isArray(arguments[0])) {
3644+
sources = arguments[0];
3645+
} else {
3646+
for(var i = 0, len = arguments.length; i < len; i++) { sources.push(arguments[i]); }
3647+
}
36323648
return new AnonymousObservable(function (observer) {
36333649
var n = sources.length,
36343650
queues = arrayInitialize(n, function () { return []; }),
@@ -4007,8 +4023,8 @@
40074023
} else {
40084024
scheduler = immediateScheduler;
40094025
}
4010-
values = slice.call(arguments, start);
4011-
return enumerableOf([observableFromArray(values, scheduler), this]).concat();
4026+
for(var args = [], i = start, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
4027+
return enumerableOf([observableFromArray(args, scheduler), this]).concat();
40124028
};
40134029

40144030
/**
@@ -5596,8 +5612,8 @@
55965612
gen = fn;
55975613

55985614
if (isGenFun) {
5599-
var args = slice.call(arguments),
5600-
len = args.length,
5615+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
5616+
var len = args.length,
56015617
hasCallback = len && typeof args[len - 1] === fnString;
56025618

56035619
done = hasCallback ? args.pop() : handleError;
@@ -5617,7 +5633,7 @@
56175633

56185634
// multiple args
56195635
if (arguments.length > 2) {
5620-
res = slice.call(arguments, 1);
5636+
for(var res = [], i = 1, len = arguments.length; i < len; i++) { res.push(arguments[i]); }
56215637
}
56225638

56235639
if (err) {
@@ -5738,7 +5754,7 @@
57385754
*/
57395755
Observable.fromCallback = function (func, context, selector) {
57405756
return function () {
5741-
var args = slice.call(arguments, 0);
5757+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
57425758

57435759
return new AnonymousObservable(function (observer) {
57445760
function handler() {
@@ -5748,8 +5764,7 @@
57485764
try {
57495765
results = selector(results);
57505766
} catch (err) {
5751-
observer.onError(err);
5752-
return;
5767+
return observer.onError(err);
57535768
}
57545769

57555770
observer.onNext(results);
@@ -5779,7 +5794,7 @@
57795794
*/
57805795
Observable.fromNodeCallback = function (func, context, selector) {
57815796
return function () {
5782-
var args = slice.call(arguments, 0);
5797+
for(var args = [], i = 0, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
57835798

57845799
return new AnonymousObservable(function (observer) {
57855800
function handler(err) {
@@ -5788,14 +5803,13 @@
57885803
return;
57895804
}
57905805

5791-
var results = slice.call(arguments, 1);
5806+
for(var results = [], i = 1, len = arguments.length; i < len; i++) { results.push(arguments[i]); }
57925807

57935808
if (selector) {
57945809
try {
57955810
results = selector(results);
57965811
} catch (e) {
5797-
observer.onError(e);
5798-
return;
5812+
return observer.onError(e);
57995813
}
58005814
observer.onNext(results);
58015815
} else {
@@ -7738,7 +7752,12 @@
77387752
* @returns {Observable} An observable sequence with an array collecting the last elements of all the input sequences.
77397753
*/
77407754
Observable.forkJoin = function () {
7741-
var allSources = argsOrArray(arguments, 0);
7755+
var allSources = [];
7756+
if (Array.isArray(arguments[0])) {
7757+
allSources = arguments[0];
7758+
} else {
7759+
for(var i = 0, len = arguments.length; i < len; i++) { allSources.push(arguments[i]); }
7760+
}
77427761
return new AnonymousObservable(function (subscriber) {
77437762
var count = allSources.length;
77447763
if (count === 0) {
@@ -7799,7 +7818,6 @@
77997818
*/
78007819
observableProto.forkJoin = function (second, resultSelector) {
78017820
var first = this;
7802-
78037821
return new AnonymousObservable(function (observer) {
78047822
var leftStopped = false, rightStopped = false,
78057823
hasLeft = false, hasRight = false,
@@ -8161,7 +8179,12 @@
81618179
* @returns {Observable} Observable sequence with the results form matching several patterns.
81628180
*/
81638181
Observable.when = function () {
8164-
var plans = argsOrArray(arguments, 0);
8182+
var plans = [];
8183+
if (Array.isArray(arguments[0])) {
8184+
plans = arguments[0];
8185+
} else {
8186+
for(var i = 0, len = arguments.length; i < len; i++) { plans.push(arguments[i]); }
8187+
}
81658188
return new AnonymousObservable(function (observer) {
81668189
var activePlans = [],
81678190
externalSubscriptions = new Map();

dist/rx.all.compat.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)