From c0a73b2ed84ab0b542fd301274924ad782f09d47 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 8 Dec 2016 18:27:49 -0800 Subject: [PATCH] Revert changes to core.ts --- src/compiler/core.ts | 61 +++----------------------------------------- 1 file changed, 4 insertions(+), 57 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 70674d400c3..72c09e490c3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -571,32 +571,13 @@ namespace ts { * @param copyOnWrite Indicates whether to return a fresh array rather than modify the * existing array. */ - export function append(to: T[] | undefined, value: T | undefined, copyOnWrite?: boolean): T[] | undefined { + export function append(to: T[] | undefined, value: T | undefined): T[] | undefined { if (value === undefined) return to; if (to === undefined) return [value]; - if (copyOnWrite) return [...to, value]; to.push(value); return to; } - /** - * Prepends a value to an array, returning the array. - * - * @param to The array to which `value` is to be prepended. If `to` is `undefined`, a new array - * is created if `value` was prepended. - * @param value The value to prepend to the array. If `value` is `undefined`, nothing is - * prepended. - * @param copyOnWrite Indicates whether to return a fresh array rather than modify the - * existing array. - */ - export function prepend(to: T[] | undefined, value: T | undefined, copyOnWrite?: boolean): T[] | undefined { - if (value === undefined) return to; - if (to === undefined) return [value]; - if (copyOnWrite) return [value, ...to]; - to.unshift(value); - return to; - } - /** * Appends a range of value to an array, returning the array. * @@ -604,45 +585,11 @@ namespace ts { * is created if `value` was appended. * @param from The values to append to the array. If `from` is `undefined`, nothing is * appended. If an element of `from` is `undefined`, that element is not appended. - * @param copyOnWrite Indicates whether to return a fresh array rather than modify the - * existing array. */ - export function addRange(to: T[] | undefined, from: T[] | undefined, copyOnWrite?: boolean): T[] | undefined { + export function addRange(to: T[] | undefined, from: T[] | undefined): T[] | undefined { if (from === undefined) return to; - from = filter(from, isDefined); - if (to === undefined) return from; - if (from.length > 0) { - if (copyOnWrite) { - return [...to, ...from]; - } - for (const v of from) { - to.push(v); - } - } - return to; - } - - /** - * Appends a range of value to an array, returning the array. - * - * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array - * is created if `value` was appended. - * @param from The values to append to the array. If `from` is `undefined`, nothing is - * appended. If an element of `from` is `undefined`, that element is not appended. - * @param copyOnWrite Indicates whether to return a fresh array rather than modify the - * existing array. - */ - export function prependRange(to: T[] | undefined, from: T[] | undefined, copyOnWrite?: boolean): T[] | undefined { - if (from === undefined) return to; - from = filter(from, isDefined); - if (to === undefined) return from; - if (from.length > 0) { - if (copyOnWrite) { - return [...from, ...to]; - } - for (let i = from.length - 1; i >= 0; i--) { - to.unshift(from[i]); - } + for (const v of from) { + to = append(to, v); } return to; }