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

Commit

Permalink
Fixing zip
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpodwysocki committed Aug 21, 2015
1 parent 96429e9 commit 78d6560
Show file tree
Hide file tree
Showing 27 changed files with 188 additions and 29 deletions.
3 changes: 3 additions & 0 deletions dist/rx.all.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4284,6 +4284,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.all.compat.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/rx.all.compat.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/rx.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4139,6 +4139,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.all.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/rx.all.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/rx.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4198,6 +4198,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.compat.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/rx.compat.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/rx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4007,6 +4007,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
3 changes: 3 additions & 0 deletions dist/rx.lite.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3685,6 +3685,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.lite.compat.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/rx.lite.compat.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/rx.lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/rx.lite.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/rx.lite.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/rx.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/rx.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions doc/api/core/operators/from.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### `Rx.Observable.from(iterable, [mapFn], [thisArg], [scheduler])`
[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/from.js "View in source")
[&#x24C8;](https://github.com/Reactive-Extensions/RxJS/blob/master/src/core/linq/observable/from.js 'View in source')

This method creates a new Observable sequence from an array-like or iterable object.

Expand Down Expand Up @@ -37,7 +37,7 @@ f(1, 2, 3).subscribe(

// Any iterable object...
// Set
var s = new Set(["foo", window]);
var s = new Set(['foo', window]);
Rx.Observable.from(s).subscribe(
function (x) {
console.log('Next: ' + x);
Expand Down Expand Up @@ -70,7 +70,7 @@ Rx.Observable.from(m).subscribe(
// => Completed

// String
Rx.Observable.from("foo").subscribe(
Rx.Observable.from('foo').subscribe(
function (x) {
console.log('Next: ' + x);
},
Expand Down
3 changes: 3 additions & 0 deletions modules/rx-lite-compat/rx.lite.compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3685,6 +3685,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion modules/rx-lite-compat/rx.lite.compat.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions modules/rx-lite-compat/rx.lite.compat.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions modules/rx-lite/rx.lite.js
Original file line number Diff line number Diff line change
Expand Up @@ -3496,6 +3496,9 @@ var FlatMapObservable = (function(__super__){
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
Expand Down
2 changes: 1 addition & 1 deletion modules/rx-lite/rx.lite.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions modules/rx-lite/rx.lite.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/core/linq/observable/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
Observable.zip = function () {
var len = arguments.length, args = new Array(len);
for(var i = 0; i < len; i++) { args[i] = arguments[i]; }
if (Array.isArray(args[0])) {
args = isFunction(args[1]) ? args[0].concat(args[1]) : args[0];
}
var first = args.shift();
return first.zip.apply(first, args);
};
132 changes: 132 additions & 0 deletions tests/observable/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,138 @@
);
});

test('zip n-ary symmetric selector', function () {
var scheduler = new TestScheduler();

var e0 = scheduler.createHotObservable(
onNext(150, 1),
onNext(210, 1),
onNext(250, 4),
onCompleted(420));

var e1 = scheduler.createHotObservable(
onNext(150, 1),
onNext(220, 2),
onNext(240, 5),
onCompleted(410));

var e2 = scheduler.createHotObservable(
onNext(150, 1),
onNext(230, 3),
onNext(260, 6),
onCompleted(400));

var res = scheduler.startWithCreate(function () {
return Observable.zip(e0, e1, e2, function (r0, r1, r2) { return [r0, r1, r2]; });
});

res.messages.assertEqual(
onNext(230, [1, 2, 3]),
onNext(260, [4, 5, 6]),
onCompleted(420)
);

e0.subscriptions.assertEqual(
subscribe(200, 420)
);

e1.subscriptions.assertEqual(
subscribe(200, 420)
);

e2.subscriptions.assertEqual(
subscribe(200, 420)
);
});

test('zip n-ary array symmetric', function () {
var scheduler = new TestScheduler();

var e0 = scheduler.createHotObservable(
onNext(150, 1),
onNext(210, 1),
onNext(250, 4),
onCompleted(420));

var e1 = scheduler.createHotObservable(
onNext(150, 1),
onNext(220, 2),
onNext(240, 5),
onCompleted(410));

var e2 = scheduler.createHotObservable(
onNext(150, 1),
onNext(230, 3),
onNext(260, 6),
onCompleted(400));

var res = scheduler.startWithCreate(function () {
return Observable.zip([e0, e1, e2])
});

res.messages.assertEqual(
onNext(230, [1, 2, 3]),
onNext(260, [4, 5, 6]),
onCompleted(420)
);

e0.subscriptions.assertEqual(
subscribe(200, 420)
);

e1.subscriptions.assertEqual(
subscribe(200, 420)
);

e2.subscriptions.assertEqual(
subscribe(200, 420)
);
});

test('zip n-ary symmetric array selector', function () {
var scheduler = new TestScheduler();

var e0 = scheduler.createHotObservable(
onNext(150, 1),
onNext(210, 1),
onNext(250, 4),
onCompleted(420));

var e1 = scheduler.createHotObservable(
onNext(150, 1),
onNext(220, 2),
onNext(240, 5),
onCompleted(410));

var e2 = scheduler.createHotObservable(
onNext(150, 1),
onNext(230, 3),
onNext(260, 6),
onCompleted(400));

var res = scheduler.startWithCreate(function () {
return Observable.zip([e0, e1, e2], function (r0, r1, r2) { return [r0, r1, r2]; });
});

res.messages.assertEqual(
onNext(230, [1, 2, 3]),
onNext(260, [4, 5, 6]),
onCompleted(420)
);

e0.subscriptions.assertEqual(
subscribe(200, 420)
);

e1.subscriptions.assertEqual(
subscribe(200, 420)
);

e2.subscriptions.assertEqual(
subscribe(200, 420)
);
});

test('zip never never', function () {
var scheduler = new TestScheduler();

Expand Down

0 comments on commit 78d6560

Please sign in to comment.