(promise)
| 469 | } |
| 470 | |
| 471 | function makeQuerablePromise(promise) { |
| 472 | if (typeof promise !== "object") { |
| 473 | throw new Error("promise is not an object.") |
| 474 | } |
| 475 | if (!(promise instanceof Promise)) { |
| 476 | throw new Error("Argument is not a promise.") |
| 477 | } |
| 478 | // Don't modify a promise that's been already modified. |
| 479 | if ("isResolved" in promise || "isRejected" in promise || "isPending" in promise) { |
| 480 | return promise |
| 481 | } |
| 482 | let isPending = true |
| 483 | let isRejected = false |
| 484 | let rejectReason = undefined |
| 485 | let isResolved = false |
| 486 | let resolvedValue = undefined |
| 487 | const qurPro = promise.then( |
| 488 | function (val) { |
| 489 | isResolved = true |
| 490 | isPending = false |
| 491 | resolvedValue = val |
| 492 | return val |
| 493 | }, |
| 494 | function (reason) { |
| 495 | rejectReason = reason |
| 496 | isRejected = true |
| 497 | isPending = false |
| 498 | throw reason |
| 499 | } |
| 500 | ) |
| 501 | Object.defineProperties(qurPro, { |
| 502 | isResolved: { |
| 503 | get: () => isResolved, |
| 504 | }, |
| 505 | resolvedValue: { |
| 506 | get: () => resolvedValue, |
| 507 | }, |
| 508 | isPending: { |
| 509 | get: () => isPending, |
| 510 | }, |
| 511 | isRejected: { |
| 512 | get: () => isRejected, |
| 513 | }, |
| 514 | rejectReason: { |
| 515 | get: () => rejectReason, |
| 516 | }, |
| 517 | }) |
| 518 | return qurPro |
| 519 | } |
| 520 | |
| 521 | /* inserts custom html to allow prettifying of inputs */ |
| 522 | function prettifyInputs(root_element) { |
no outgoing calls
no test coverage detected