This commit is contained in:
Dmitry Vasilev
2022-12-17 13:55:37 +08:00
parent 769ca707eb
commit d43c4ee71c
3 changed files with 26 additions and 6 deletions

View File

@@ -21,8 +21,8 @@ const isError = object =>
object instanceof globalThis.run_window.Error
const isPromise = object =>
object instanceof Promise
||
object instanceof Promise
||
object instanceof globalThis.run_window.Promise
const displayed_entries = object => {
@@ -49,7 +49,15 @@ export const stringify_for_header = v => {
// TODO clickable link, 'fn', cursive
return 'fn ' + v.name
} else if (isPromise(v)) {
return 'Promise<>'
if(v.status == null) {
return `Promise<pending>`
} else {
if(status.ok) {
return `Promise<fulfilled: ${stringify_for_header(status.value)}>`
} else {
return `Promise<fulfilled: ${stringify_for_header(status.error)}>`
}
}
} else if(isError(v)) {
return v.toString()
} else if(type == 'object') {

View File

@@ -5,11 +5,11 @@ export const patch_promise = window => {
return
}
class PromiseWithStatus extends Promise {
class PromiseWithStatus extends window.Promise {
constructor(fn) {
let status
let is_constructor_finished = false
const p = new Promise.Original(
const p = new window.Promise.Original(
(resolve, reject) => {
fn(
(value) => {
@@ -47,7 +47,7 @@ export const patch_promise = window => {
}
}
PromiseWithStatus.Original = Promise
PromiseWithStatus.Original = window.Promise
window.Promise = PromiseWithStatus
}