修复问题

This commit is contained in:
子沐呀
2024-07-19 00:17:48 +08:00
Unverified
parent 55424a447b
commit c544569bd8
6 changed files with 67 additions and 52 deletions
+12 -7
View File
@@ -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 {