@buession/prototype
Version:
A native object extension framework for Javascript.
29 lines • 819 B
JavaScript
/**
* Function 对象扩展
*/
/**
* 获取函数参数名称
*
* @return 函数参数名称列表
*/
Function.prototype.argumentNames = function () {
var method = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/);
if (method === null) {
return null;
}
var names = method[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, "").replace(/\s+/g, "").split(", ");
return names.length === 1 && !names[0] ? [] : names;
};
/**
* 延时执行函数
*
* @param timeout 延时时间(单位:秒)
* @return mixed
*/
Function.prototype.delay = function (timeout) {
var __method = this;
var args = Array.prototype.slice.call(arguments, 1);
return window.setTimeout(__method.apply(__method, args), timeout * 1000);
};
//# sourceMappingURL=function.js.map
;