修复问题
This commit is contained in:
@@ -25,19 +25,24 @@ Function.prototype.getName =
|
||||
* @returns {string}
|
||||
*/
|
||||
function () {
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || this.toString().hashCode().toString(16);
|
||||
return this.name || this.toString().match(/function\s*([^(]*)\(/)?.[1] || getStringHashCode(this.toString()).toString(16);
|
||||
}
|
||||
|
||||
String.prototype.hashCode = function () {
|
||||
var hash = 0, i, chr;
|
||||
if (this.length === 0) return hash;
|
||||
for (i = 0; i < this.length; i++) {
|
||||
chr = this.charCodeAt(i);
|
||||
/**
|
||||
* 获取字符串哈希值
|
||||
* @param {string} str 字符串
|
||||
* @returns {number}
|
||||
*/
|
||||
function getStringHashCode(str) {
|
||||
let hash = 0, chr;
|
||||
if (str.length === 0) return hash;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0;
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
}
|
||||
|
||||
/** PAPI变量类 */
|
||||
class PAPI {
|
||||
|
||||
Reference in New Issue
Block a user