feat: Add fallback to Symbol.for(…)#30
Open
ExE-Boss wants to merge 1 commit intoinspect-js:mainfrom
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #30 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 206 210 +4
Branches 75 77 +2
=========================================
+ Hits 206 210 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
87460ef to
3a485db
Compare
ljharb
requested changes
Feb 1, 2020
| }; | ||
|
|
||
| if (inspectSymbol) { | ||
| module.exports.custom = inspectSymbol; |
Member
There was a problem hiding this comment.
i'd prefer not to re-export this.
Suggested change
| module.exports.custom = inspectSymbol; |
| var inspectCustom = require('./util.inspect').custom; | ||
| /* eslint-disable no-restricted-properties */ | ||
| if (!inspectCustom && typeof Symbol === 'function' && typeof Symbol['for'] === 'function') { | ||
| inspectCustom = Symbol['for']('nodejs.util.inspect.custom'); |
Member
There was a problem hiding this comment.
This will mean that in the browser, however, a symbol will be registered and usable. it seems to me that util.inspect's custom symbol should only ever work in node.
Member
There was a problem hiding this comment.
Also, this logic only helps in node >= 10.12; the dependency is still required for node 6.6-10.11, so i don’t see the value in this added complexity.
7363e8f to
c2d7746
Compare
7ada44f to
431bab2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Node 10.12 and newer registers the
util.inspect.customsymbol asnodejs.util.inspect.custom, making it possible to useSymbol.for('nodejs.util.inspect.custom')to get the equivalentutil.inspect.customsymbol without depending onutil.