get.stringify添加解析GameEvemtPromise的情况

This commit is contained in:
nonameShijian 2024-01-23 17:31:36 +08:00
parent 0bda9fec34
commit 5c43b7fd0e
1 changed files with 15 additions and 15 deletions

View File

@ -689,19 +689,19 @@ export class Get extends Uninstantable {
} }
static stringify(obj, level) { static stringify(obj, level) {
level = level || 0; level = level || 0;
var indent = ''; let indent = '';
var str; let str;
for (var i = 0; i < level; i++) { for (let i = 0; i < level; i++) {
indent += ' '; indent += ' ';
} }
if (get.objtype(obj) == 'object') { if (get.objtype(obj) == 'object' || obj instanceof lib.element.GameEventPromise) {
str = '{\n'; str = '{\n';
for (var i in obj) { for (let i in obj) {
var insertDefaultString; let insertDefaultString;
var insertFunctionString = indent + ' ' + get.stringify(obj[i], level + 1) + ',\n'; let insertFunctionString = indent + ' ' + get.stringify(obj[i], level + 1) + ',\n';
var parseFunction = i => { let parseFunction = i => {
var string = obj[i].toString(); // let string = obj[i].toString();
var execResult; let execResult;
if (obj[i] instanceof GeneratorFunction) { if (obj[i] instanceof GeneratorFunction) {
// *content(){} // *content(){}
execResult = new RegExp(`\\*\\s*${i}[\\s\\S]*?\\(`).exec(obj[i]); execResult = new RegExp(`\\*\\s*${i}[\\s\\S]*?\\(`).exec(obj[i]);
@ -759,9 +759,9 @@ export class Get extends Uninstantable {
if (typeof obj == 'function') { if (typeof obj == 'function') {
str = obj.toString(); str = obj.toString();
str = str.replace(/\t/g, ' '); str = str.replace(/\t/g, ' ');
var i = str.lastIndexOf('\n'); let i = str.lastIndexOf('\n');
var num = 0; let num = 0;
for (var j = i + 1; j < str.length && str[j] == ' '; j++) { for (let j = i + 1; j < str.length && str[j] == ' '; j++) {
num++; num++;
} }
num = Math.floor(num / 4); num = Math.floor(num / 4);
@ -773,8 +773,8 @@ export class Get extends Uninstantable {
try { try {
if (Array.isArray(obj) && obj.includes(Infinity)) { if (Array.isArray(obj) && obj.includes(Infinity)) {
obj = obj.slice(0); obj = obj.slice(0);
var rand = get.id(); let rand = get.id();
for (var i = 0; i < obj.length; i++) { for (let i = 0; i < obj.length; i++) {
if (obj[i] === Infinity) { if (obj[i] === Infinity) {
obj[i] = parseInt(rand); obj[i] = parseInt(rand);
} }