Skip to content

How do I implement MyObject.inspect(depth, inspectOpts)? #8442

Description

@Havvy

I want to implement inspect for my own object. I want to mostly follow the semantics of inspect for non-custom implementations, but just by going by the documentation alone, I have no possible way of doing so. What conventions are there? How do I recursively call inspect while respecting depth? Do I need to handle the case of depth being null?

The example ignores the parameters passed to it completely currently. Maybe if we had an example of a Box object that inspects as "Box<InnerInspectValue>" so e.g. inspect({value: "a", inspect: ... }) returns "Box<'a'>" but the value can be anything (including over objects with custom inspect impls).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to Node.js documentation.good first issueIssues that are suitable for first-time contributors.questionIssues asking questions about Node.js.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions