Skip to content

Commit

Permalink
fix(merge): single array is not an array of sources (#6211)
Browse files Browse the repository at this point in the history
* test(merge): add failing single-array test

* fix(merge): single array is not an array of sources
  • Loading branch information
cartant authored Apr 9, 2021
1 parent e4ba925 commit 4e900dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions spec/observables/merge-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,10 @@ describe('merge(...observables, Scheduler, number)', () => {

expect(e1Subscribed).to.be.false;
});

it('should deem a single array argument to be an ObservableInput', () => {
const array = ['foo', 'bar'];
const expected = '(fb|)';
expectObservable(merge(array)).toBe(expected, { f: 'foo', b: 'bar' });
});
});
3 changes: 1 addition & 2 deletions src/internal/observable/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Observable } from '../Observable';
import { ObservableInput, ObservableInputTuple, SchedulerLike } from '../types';
import { mergeAll } from '../operators/mergeAll';
import { internalFromArray } from './fromArray';
import { argsOrArgArray } from '../util/argsOrArgArray';
import { innerFrom } from './from';
import { EMPTY } from './empty';
import { popNumber, popScheduler } from '../util/args';
Expand Down Expand Up @@ -88,7 +87,7 @@ export function merge<A extends readonly unknown[]>(
export function merge(...args: (ObservableInput<unknown> | number | SchedulerLike)[]): Observable<unknown> {
const scheduler = popScheduler(args);
const concurrent = popNumber(args, Infinity);
const sources = argsOrArgArray(args) as ObservableInput<unknown>[];
const sources = args as ObservableInput<unknown>[];
return !sources.length
? // No source provided
EMPTY
Expand Down

0 comments on commit 4e900dc

Please sign in to comment.