Skip to content
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

Import Node 10.9.0. Redo the fix for util.inspect.custom #357

Merged
merged 3 commits into from
Aug 20, 2018
Merged

Conversation

mcollina
Copy link
Member

Fixes #355

@vweevers
Copy link
Contributor

Is this still needed?

// TODO: add replacements instead
if (!util.inspect) {
util.inspect = function () {};
util.inspect.custom = 'custom';
}

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but the fallback for custom inspection should be 'inspect'.

var _require2 = require('util'),
inspect = _require2.inspect;

var custom = inspect && custom || Symbol('useless');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using Symbol('useless') fall back to 'inspect'. That way old Node versions should work properly.

const Buffer = require('buffer').Buffer
const util = require('util')
const { inspect } = require('util')
const custom = inspect && inspect.custom || 'inspect'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this browserify all of util? I wrote https://github.com/mafintosh/inspect-custom-symbol to get around that (util is pretty big!)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mafintosh that module uses the symbol instead of 'inspect' as a key. See https://github.com/mafintosh/inspect-custom-symbol/blob/master/index.js#L4. @BridgeAR should we use the symbol or the property here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see #356 to remove the use of util.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be 'inspect'. Otherwise old Node.js versions won't work and a symbol has no other effect on browserify in this case than the string.

I don't use browserify often enough to know exactly what it would pull in but it should only be the parts that are used and in this case it is only the inspection property. So that should be fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should land this as is and deal with removing util in #356. What do you think? May I get a couple of LGTM?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BridgeAR it pulls in the entire util source. that's why people use the inherits module instead of util.inherits on npm also :)

@mcollina Ya, solving it elsewhere is fine by me

@mafintosh
Copy link
Member

Added a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants