Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

promise.inspect() #256

@domenic

Description

@domenic

I think the synchronous inspection API we have currently is clunky. My ideal one would look like promise.inspect() (or inspectState, or snapshot, or stateSnapshot, ...), which returns a "snapshot" object that is one of:

  • { state = "pending" }
  • { state = "fulfilled", value }
  • { state = "rejected", reason }

The advantage of this over promise.state, promise.value, and promise.reason are:

  • In ES3, properties on the promise have to be mutable, which is confusing.
  • Even in ES5, if we were to make those getters, I think it's less-clear that they are a read-only API than a snapshot-returning function.
  • Reduced surface area.
  • Usefulness for Q.allSettled (see Q.allSettled #257).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions