vue-hooks-plus
Version:
Vue hooks library
53 lines (52 loc) • 1.45 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
class HashTable {
constructor() {
__publicField(this, "table", {});
__publicField(this, "hashTable", {});
}
insert(str) {
const symbolCode = Symbol(str);
this.table[str] = true;
this.hashTable[symbolCode] = str;
return symbolCode;
}
find(symbolCode) {
return this.hashTable[symbolCode];
}
}
const HashTableInstance = new HashTable();
function getFunctionName(func) {
const funcString = func.toString();
const match = funcString.match(/^function\s+([^\s(]+)/);
return match ? match[1] : "";
}
function getArrowFunctionName(func) {
const funcString = func.toString();
const regex = /([a-zA-Z$_][a-zA-Z0-9$_]*)\s*\(/;
const match = funcString.match(regex);
return match ? match[1].trim() : "";
}
function getRequestTagBg(type) {
if (type === "pending")
return 16747520;
if (type === "done")
return 6586111;
if (type === "error")
return 16724736;
if (type === "cancel")
return 10500409;
if (type === "mutate")
return 27647;
return 4873398;
}
export {
HashTableInstance,
getArrowFunctionName,
getFunctionName,
getRequestTagBg
};