Skip to content

Feature request: utilize Symbol.toStringTag in util.inspect #12780

Description

Sample usage is HTML tree, where every child node is named according to its type.

class Node extends Array
{
    constructor(type = 'InputElement', children = [])
    {
        super(...children);
        this.type = type;
    }
    [Symbol.toStringTag]()
    {
        return this.type;
    }
}

Example of print to console:

HTMLElement [
    HeadElement [
        ....
    ]
    BodyElement [
        ....
    ]
]

(edited by @vsemozhetbyt: added backticks for code blocks)

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

    feature requestIssues requesting new Node.js features.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