diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-08-19 00:26:36 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-08-25 07:13:00 +0200 |
commit | 59714cb7b3918c9e4fcd94013b778078d3710705 (patch) | |
tree | 5afd381dffd5b89def62b501f6a955acc778a517 /lib/internal/util.js | |
parent | 6e50fc763700de31388580d701ebe4b3a507e673 (diff) | |
download | android-node-v8-59714cb7b3918c9e4fcd94013b778078d3710705.tar.gz android-node-v8-59714cb7b3918c9e4fcd94013b778078d3710705.tar.bz2 android-node-v8-59714cb7b3918c9e4fcd94013b778078d3710705.zip |
util: allow symbol-based custom inspection methods
Add a `util.inspect.custom` Symbol which can be used to customize
`util.inspect()` output. Providing `obj[util.inspect.custom]`
works like providing `obj.inspect`, except that the former allows
avoiding name clashes with other `inspect()` methods.
Fixes: https://github.com/nodejs/node/issues/8071
PR-URL: https://github.com/nodejs/node/pull/8174
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <mic.besace@gmail.com>
Diffstat (limited to 'lib/internal/util.js')
-rw-r--r-- | lib/internal/util.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/internal/util.js b/lib/internal/util.js index 055f8779b1..7f93e1a2e0 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -9,6 +9,10 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; exports.getHiddenValue = binding.getHiddenValue; exports.setHiddenValue = binding.setHiddenValue; +// The `buffer` module uses this. Defining it here instead of in the public +// `util` module makes it accessible without having to `require('util')` there. +exports.customInspectSymbol = Symbol('util.inspect.custom'); + // All the internal deprecations have to use this function only, as this will // prepend the prefix to the actual message. exports.deprecate = function(fn, msg) { |