UNPKG

fun-exp

Version:

fun-exp 通过 Function.prototype 对函数对象进行了扩展

2 lines (1 loc) 679 B
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";Function.prototype.before=function(t){var n=this;return function(){var r=t.apply(this,arguments);return null==r&&(r=arguments),n.apply(this,r)}},Function.prototype.after=function(t){var n=this;return function(){var r=n.apply(this,arguments);return t.call.apply(t,[this,r].concat(Array.prototype.slice.call(arguments)))}},Function.prototype.wrap=function(t,n){var r=this;return t&&n?function(){var n,i=t.apply(this,arguments);null==i&&(i=arguments);var e=r.apply(this,i);return(n=fun).call.apply(n,[this,e].concat(Array.prototype.slice.call(arguments)))}:t?r.before(t):n?r.after(n):r}}));