mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	allows to break out of $tw.utils.each
Will improve performance with `$tw.utils.each` callbacks breaking out of the iteration via `return false;`.
This commit is contained in:
		
							
								
								
									
										11
									
								
								boot/boot.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								boot/boot.js
									
									
									
									
									
								
							| @@ -62,14 +62,19 @@ $tw.utils.isDate = function(value) { | |||||||
| Iterate through all the own properties of an object or array. Callback is invoked with (element,title,object) | Iterate through all the own properties of an object or array. Callback is invoked with (element,title,object) | ||||||
| */ | */ | ||||||
| $tw.utils.each = function(object,callback) { | $tw.utils.each = function(object,callback) { | ||||||
| 	var f; | 	var next, f; | ||||||
|  |  | ||||||
| 	if(object) { | 	if(object) { | ||||||
| 		if(Object.prototype.toString.call(object) == "[object Array]") { | 		if(Object.prototype.toString.call(object) == "[object Array]") { | ||||||
| 			object.forEach(callback); | 			for (f = 0; f < object.length; f++) { | ||||||
|  | 				next = callback(object[f],f); | ||||||
|  | 				if (next === false) break; | ||||||
|  | 		    } | ||||||
| 		} else { | 		} else { | ||||||
| 			for(f in object) { | 			for(f in object) { | ||||||
| 				if(Object.prototype.hasOwnProperty.call(object,f)) { | 				if(Object.prototype.hasOwnProperty.call(object,f)) { | ||||||
| 					callback(object[f],f,object); | 					next = callback(object[f],f,object); | ||||||
|  | 					if (next === false) break; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Tobias Beer
					Tobias Beer