/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ export const empty = Object.freeze([]); export function equals( a: ReadonlyArray, b: ReadonlyArray, itemEquals: (a: T, b: T) => boolean = (a, b) => a === b ): boolean { if (a === b) { return true; } if (a.length !== b.length) { return false; } return a.every((x, i) => itemEquals(x, b[i])); } export function flatten(array: ReadonlyArray[]): T[] { return Array.prototype.concat.apply([], array); } export function coalesce(array: ReadonlyArray): T[] { return array.filter(e => !!e); }