forked from MapComplete/MapComplete
		
	Improve utils: add documentation and test of NoEmpty, return empty list if undefined
This commit is contained in:
		
							parent
							
								
									a8a5ce8ded
								
							
						
					
					
						commit
						b728cbd90a
					
				
					 1 changed files with 11 additions and 0 deletions
				
			
		
							
								
								
									
										11
									
								
								Utils.ts
									
										
									
									
									
								
							
							
						
						
									
										11
									
								
								Utils.ts
									
										
									
									
									
								
							|  | @ -268,8 +268,19 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be | ||||||
|         return hist |         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[] { |     public static NoEmpty(array: string[]): string[] { | ||||||
|         const ls: string[] = [] |         const ls: string[] = [] | ||||||
|  |         if(!array){ | ||||||
|  |             return ls | ||||||
|  |         } | ||||||
|         for (const t of array) { |         for (const t of array) { | ||||||
|             if (t === "") { |             if (t === "") { | ||||||
|                 continue |                 continue | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue