mirror of
				https://github.com/flynx/object-run.js.git
				synced 2025-10-29 19:10:08 +00:00 
			
		
		
		
	
		
			
	
	
		
			31 lines
		
	
	
		
			909 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			31 lines
		
	
	
		
			909 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|  | /********************************************************************** | ||
|  | *  | ||
|  | * object-run.js | ||
|  | * | ||
|  | * Repo and docs: | ||
|  | * 	https://github.com/flynx/object-run.js
 | ||
|  | * | ||
|  | * | ||
|  | ***********************************************/ /* c8 ignore next 2 */ | ||
|  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | ||
|  | (function(require){ var module={} // make module AMD/node compatible...
 | ||
|  | /*********************************************************************/ | ||
|  | 
 | ||
|  | // Run a function in the context of an object...
 | ||
|  | //
 | ||
|  | Object.prototype.run | ||
|  | 	|| Object.defineProperty(Object.prototype, 'run', { | ||
|  | 		enumerable: false, | ||
|  | 		value: function(func){ | ||
|  | 			var res = func ?  | ||
|  | 				func.call(this)  | ||
|  | 				: undefined | ||
|  | 			return res === undefined ?  | ||
|  | 				this  | ||
|  | 				: res }, }) | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | /********************************************************************** | ||
|  | * vim:set ts=4 sw=4 :                               */ return module }) |