mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Remove extra null checks in coalesce
The type system should catch these now
This commit is contained in:
@@ -293,12 +293,9 @@ function topStep<T>(array: ReadonlyArray<T>, compare: (a: T, b: T) => number, re
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns a new array with all falsy values removed. The original array IS NOT modified.
|
||||
* @returns New array with all falsy values removed. The original array IS NOT modified.
|
||||
*/
|
||||
export function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[] {
|
||||
if (!array) {
|
||||
return array;
|
||||
}
|
||||
return <T[]>array.filter(e => !!e);
|
||||
}
|
||||
|
||||
@@ -306,9 +303,6 @@ export function coalesce<T>(array: ReadonlyArray<T | undefined | null>): T[] {
|
||||
* Remove all falsey values from `array`. The original array IS modified.
|
||||
*/
|
||||
export function coalesceInPlace<T>(array: Array<T | undefined | null>): void {
|
||||
if (!array) {
|
||||
return;
|
||||
}
|
||||
let to = 0;
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (!!array[i]) {
|
||||
|
||||
Reference in New Issue
Block a user