Improve utils: add documentation and test of NoEmpty, return empty list if undefined

This commit is contained in:
Pieter Vander Vennet 2023-02-03 03:55:33 +01:00
parent a8a5ce8ded
commit b728cbd90a

View file

@ -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