-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use util.inspect.custom
symbol if available.
#204
Conversation
Ports the `buffer-inspect` test from Node core. Adds a `Buffer.prototype[util.inspect.custom]` method, which is an alias to `Buffer.prototype.inspect`. Node already doesn't have an `.inspect` method on Buffers anymore, but since this module has to work in browsers that do not have Symbols, it seems better to keep it around. In Node, this will use the builtin `util.inspect.custom` symbol. In the browser, it will use `Symbol.for('util.inspect.custom')`. The browser version of `util` will also use the `inspect-custom-symbol` module in the near future. If nodejs/node#20857 gets merged, `Symbol.for('util.inspect.custom')` will be used everywhere and the dependency on `inspect-custom-symbol` could probably be dropped. The motivation for this is API parity and the fact that Node is removing support for the old `.inspect` method: nodejs/node#20722
Hi @goto-bus-stop, I'm down to merge this PR. But I noticed that Node.js ended up going with Thanks for pointing out that |
Will try to update later today 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
5.4.0 |
Not sure how this relevant and correct, but Maybe? typeof Symbol !== 'undefined' && typeof Symbol.for === 'function' |
@fanatid Nice catch. However, Chrome 40 was released on 2015-01-21. I don't think anyone is still running that version, and we only officially support the last 2 versions of Chrome. |
|
Ports the
buffer-inspect
test from Node core.Adds a
Buffer.prototype[util.inspect.custom]
method, which is an aliasto
Buffer.prototype.inspect
. Node already doesn't have an.inspect
method on Buffers anymore, but since this module has to work in browsers
that do not have Symbols, it seems better to keep it around.
In Node, this will use the builtin
util.inspect.custom
symbol. In thebrowser, it will use
Symbol.for('util.inspect.custom')
. The browserversion of
util
will also use theinspect-custom-symbol
module inthe near future.
If nodejs/node#20857 gets merged,
Symbol.for('util.inspect.custom')
will be used everywhere and thedependency on
inspect-custom-symbol
could probably be dropped.The motivation for this is API parity and the fact that Node is
removing support for the old
.inspect
method:nodejs/node#20722