diff --git a/Utils.ts b/Utils.ts index 6ed49a2fa..1b97d00a2 100644 --- a/Utils.ts +++ b/Utils.ts @@ -268,8 +268,19 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be return hist } + /** + * Removes all empty strings from this list + * If undefined or null is given, an empty list is returned + * + * Utils.NoEmpty(undefined) // => [] + * Utils.NoEmpty(["abc","","def", null]) // => ["abc","def", null] + * + */ public static NoEmpty(array: string[]): string[] { const ls: string[] = [] + if(!array){ + return ls + } for (const t of array) { if (t === "") { continue