| 
									
										
										
										
											2023-07-12 19:40:41 +02:00
										 |  |  | import * as plugins from '../smartobject.plugins.js'; | 
					
						
							| 
									
										
										
										
											2022-03-07 15:28:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * runs a function for all properties of an object whose key matches a regex expression | 
					
						
							|  |  |  |  * @param parentObjectArg the parent object | 
					
						
							|  |  |  |  * @param wildcardArg the rege expression to match the property keys against | 
					
						
							|  |  |  |  * @param callbackArg the function to run with those properties | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2023-07-12 19:40:41 +02:00
										 |  |  | export let forEachMinimatch = async ( | 
					
						
							|  |  |  |   parentObjectArg: any, | 
					
						
							|  |  |  |   wildcardArg: string, | 
					
						
							|  |  |  |   callbackArg: (matchedArg: string) => void | 
					
						
							|  |  |  | ) => { | 
					
						
							| 
									
										
										
										
											2022-03-07 15:28:32 +01:00
										 |  |  |   let propertyNames = Object.getOwnPropertyNames(parentObjectArg); | 
					
						
							| 
									
										
										
										
											2023-07-12 19:40:41 +02:00
										 |  |  |   let propertyNamesMatched = propertyNames.filter((propertyNameArg) => { | 
					
						
							| 
									
										
										
										
											2023-07-12 19:59:28 +02:00
										 |  |  |     return plugins.minimatch.minimatch(propertyNameArg, wildcardArg); | 
					
						
							| 
									
										
										
										
											2022-03-07 15:28:32 +01:00
										 |  |  |   }); | 
					
						
							|  |  |  |   for (let propertyNameArg of propertyNamesMatched) { | 
					
						
							|  |  |  |     await callbackArg(parentObjectArg[propertyNameArg]); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-07-12 19:40:41 +02:00
										 |  |  | }; |