object-run.js/run.js
Alex A. Naanou b1cc554262 initial commit...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2020-07-02 16:00:40 +03:00

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 })