From 72ded7b4edbe7fe1cec7090b3c527ec105bf9657 Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Wed, 21 Feb 2018 09:12:23 -0800 Subject: [PATCH] fix(toArray): do not mutate array per subscription --- src/operators/toArray.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/operators/toArray.ts b/src/operators/toArray.ts index 3b11ffe27d..2148ad3e80 100644 --- a/src/operators/toArray.ts +++ b/src/operators/toArray.ts @@ -2,6 +2,9 @@ import { reduce } from './reduce'; import { OperatorFunction } from '../interfaces'; function toArrayReducer(arr: T[], item: T, index: number) { + if (index === 0) { + return [item]; + } arr.push(item); return arr; }