inspect-js / inspect-js/object-inspect

Support for prototype

Open
#14 12 comments 0 reactions 0 assignees View on GitHub
enhancement question
Dominant language
JavaScript
Stars
160
Forks
45
PR merge metrics
No merged PRs in 30d

Description

This package is great for creating debug output! I just compared it to a number of similar packages (`eyes`, `jsenc`, `js-stringify`, `javascript-stringify`, and `stringify-object`), and the output of `object-inspect` was by far the most helpful!

There is only one case where I'd love a bit more information, and that is when working with prototypes / ES2015 classes. Consider this code:

```js
const str = require('object-inspect');

class Foo {
constructor() {
this.a = 1;
this.b = 2;
this.c = 42;
}
}

console.log(str(new Foo()));
```

The output is `{ a: 1, b: 2, c: 42 }`, so the information that this is an instance of class `Foo` gets lost.

I noticed that for certain built-in types like `Map`, you prefix the output with the class name. It would help me a lot if you could do the same for other prototypes. In my case, that would make the output `Foo { a: 1, b: 2, c: 42 }`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.