mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
API: Improve built-in print APIs when printing Promise objects (#1710)
This commit is contained in:
parent
bc51733fbe
commit
867f79c5ab
@ -256,7 +256,16 @@ function argsToString(args: unknown[]): string {
|
|||||||
return (out += `< Set: ${[...nativeArg].join("; ")} >`);
|
return (out += `< Set: ${[...nativeArg].join("; ")} >`);
|
||||||
}
|
}
|
||||||
if (typeof nativeArg === "object") {
|
if (typeof nativeArg === "object") {
|
||||||
return (out += JSON.stringify(nativeArg));
|
return (out += JSON.stringify(nativeArg, (_, value) => {
|
||||||
|
/**
|
||||||
|
* If the property is a promise, we will return a string that clearly states that it's a promise object, not a
|
||||||
|
* normal object. If we don't do that, all promises will be serialized into "{}".
|
||||||
|
*/
|
||||||
|
if (value instanceof Promise) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (out += `${nativeArg}`);
|
return (out += `${nativeArg}`);
|
||||||
|
Loading…
Reference in New Issue
Block a user