Skip to content

Commit 27855c6

Browse files
josepotbenlesh
andauthored
fix(mergeWith): works correctly with an Array (#7281)
* fix(mergeWith): works correctly with an Array * test: just use a synchronous test to ensure it doesn't emit more or less than it's supposed to (including emitting undefineds). * test: fix `mergeWith` test --------- Co-authored-by: Ben Lesh <ben@benlesh.com>
1 parent 9db6563 commit 27855c6

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

spec/operators/mergeWith-spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,24 @@ describe('merge operator', () => {
4646
});
4747
});
4848

49+
it('should merge a source with a second, when the second is just a plain array', (done) => {
50+
const a = of(1, 2, 3);
51+
const b = [4, 5, 6, 7, 8];
52+
const r = [1, 2, 3, 4, 5, 6, 7, 8];
53+
54+
a.pipe(mergeWith(b)).subscribe({
55+
next: (val) => {
56+
expect(val).to.equal(r.shift());
57+
},
58+
error: () => {
59+
done(new Error('should not be called'));
60+
},
61+
complete: () => {
62+
done();
63+
},
64+
});
65+
});
66+
4967
it('should merge cold and cold', () => {
5068
rxTestScheduler.run(({ cold, expectObservable, expectSubscriptions }) => {
5169
const e1 = cold(' ---a-----b-----c----|');

src/internal/operators/merge.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { ObservableInput, ObservableInputTuple, OperatorFunction, SchedulerLike } from '../types';
22
import { operate } from '../util/lift';
3-
import { argsOrArgArray } from '../util/argsOrArgArray';
43
import { mergeAll } from './mergeAll';
54
import { popNumber, popScheduler } from '../util/args';
65
import { from } from '../observable/from';
@@ -23,7 +22,6 @@ export function merge<T, A extends readonly unknown[]>(
2322
export function merge<T>(...args: unknown[]): OperatorFunction<T, unknown> {
2423
const scheduler = popScheduler(args);
2524
const concurrent = popNumber(args, Infinity);
26-
args = argsOrArgArray(args);
2725

2826
return operate((source, subscriber) => {
2927
mergeAll(concurrent)(from([source, ...(args as ObservableInput<T>[])], scheduler)).subscribe(subscriber);

0 commit comments

Comments
 (0)