You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					15 lines
				
				311 B
			
		
		
			
		
	
	
					15 lines
				
				311 B
			| 
											3 years ago
										 | // Returns a function that will only be executed up to (but not including) the
 | ||
|  | // Nth call.
 | ||
|  | function before(times, func) { | ||
|  |   var memo; | ||
|  |   return function() { | ||
|  |     if (--times > 0) { | ||
|  |       memo = func.apply(this, arguments); | ||
|  |     } | ||
|  |     if (times <= 1) func = null; | ||
|  |     return memo; | ||
|  |   }; | ||
|  | } | ||
|  | 
 | ||
|  | module.exports = before; |