summaryrefslogtreecommitdiff
path: root/lib/util.js
AgeCommit message (Collapse)Author
2018-07-18util: improve display of iterators and weak entriesRuben Bridgewater
This adds the number of not visible elements when inspecting iterators while exceeding `maxArrayLength`. It also fixes a edge case with `maxArrayLength` and the map.entries() iterator. Now the whole entry will be visible instead of only the key but not the value of the first entry. Besides that it uses a slighly better algorithm that improves the performance by skipping unnecessary steps. PR-URL: https://github.com/nodejs/node/pull/20961 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-07-16util: do not escape single quotes if not necessaryRuben Bridgewater
Right now util.inspect will always escape single quotes. That is not necessary though in case the string that will be escaped does not contain double quotes. In that case the string can simply be wrapped in double quotes instead. If the string contains single and double quotes and it does not contain `${` as part of the string, backticks will be used instead. That makes sure only very few strings have to escape quotes at all. Thus it increases the readability of these strings. PR-URL: https://github.com/nodejs/node/pull/21624 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-07-16console,util: avoid pair array generation in C++Anna Henningsen
Use a plain `[key, value, key, value]`-style list instead of an array of pairs for inspecting collections. This also fixes a bug with `console.table()` where inspecting a non-key-value `MapIterator` would have led to odd results. PR-URL: https://github.com/nodejs/node/pull/20831 Refs: https://github.com/nodejs/node/pull/20719#discussion_r189342513 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-06-27util: add inspect suffix to BigInt64Array elementsTeddy Katz
This commit updates `util.inspect` to add an `n` suffix to BigInts that appear in BigInt64Arrays. BigInts are formatted with an `n` suffix in most cases, but this did not occur in BigInt64Arrays due to an apparent oversight where the implementation of `inspect` for typed arrays assumed that all typed array elements are numbers. PR-URL: https://github.com/nodejs/node/pull/21499 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
2018-06-24util: recover from maximum call stack sizeRuben Bridgewater
Using util.inspect should still return values in case the maximum call stack size is reached. This is important to inspect linked lists and similar. PR-URL: https://github.com/nodejs/node/pull/20725 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-06-02lib: use focused ESLint disabling in util.jsRich Trott
Instead of disabling all ESLint rules for two lines that require a violation of no-control-regex, disable only the no-control-regex rule. PR-URL: https://github.com/nodejs/node/pull/21041 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-30util: fix inspection of module namespacesGus Caplan
PR-URL: https://github.com/nodejs/node/pull/20962 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-21util: improve error inspectionRuben Bridgewater
When inspecting errors with extra properties while setting the compact option to false, it will now return: [Error: foo] { at repl:1:5 at Script.runInThisContext (vm.js:89:20) bla: true } Instead of: Error: foo at repl:1:5 at Script.runInThisContext (vm.js:91:20) { bla: true } PR-URL: https://github.com/nodejs/node/pull/20802 Refs: https://github.com/nodejs/node/issues/20253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-21util: fix inspected stack indentationRuben Bridgewater
Error stacks and multiline error messages were not correct indented. This is fixed by this patch. PR-URL: https://github.com/nodejs/node/pull/20802 Refs: https://github.com/nodejs/node/issues/20253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-21util: remove erroneous whitespaceRuben Bridgewater
When inspecting nested objects some times a whitespace was added at the end of a line. This fixes this erroneous space. Besides that the `breakLength` was not followed if a single property was longer than the breakLength. It will now break a single property into the key and value in such cases. PR-URL: https://github.com/nodejs/node/pull/20802 Refs: https://github.com/nodejs/node/issues/20253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-21util: wrap error in brackets without stackRuben Bridgewater
This aligns the visualization of an error with no stack traces set to zero just as it is done in case the error has no stack trace. PR-URL: https://github.com/nodejs/node/pull/20802 Refs: https://github.com/nodejs/node/issues/20253 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-05-20util: change items unknown styleRuben Bridgewater
We mainly use <> to visualize special information that is not directly visible as property. PR-URL: https://github.com/nodejs/node/pull/20792 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2018-05-19util: remove custom inspection functionRuben Bridgewater
This removes the deprecated custom inspection function and fixes all tests accordingly. Refs: https://github.com/nodejs/node/issues/15549 PR-URL: https://github.com/nodejs/node/pull/20722 Refs: https://github.com/nodejs/node/issues/15549 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-18util: support inspecting namespaces of unevaluated modulesGus Caplan
PR-URL: https://github.com/nodejs/node/pull/20782 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-05-19lib,src: use V8 API for collection inspectionAnna Henningsen
Use a new public V8 API for inspecting weak collections and collection iterators, rather than using V8-internal functions to achieve this. This currently comes with a slight modification of the output for inspecting iterators generated by `Set().entries()`. Fixes: https://github.com/nodejs/node/issues/20409 PR-URL: https://github.com/nodejs/node/pull/20719 Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-18assert,util: lazy load comparison functionsRuben Bridgewater
PR-URL: https://github.com/nodejs/node/pull/20567 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2018-05-11Revert "util: change util.inspect depth default"Anna Henningsen
This reverts commit b994b8eff6018433a56bb10dbc473cefa0dd9370. This caused regressions in ecosystem code. While the change originally was semver-major and could be postponed until after Node.js 10, I think reverting it is a good choice at this point. Also, I personally do not think defaulting to a shallow inspect is a bad thing at all – quite the opposite: It makes `util.inspect()` give an overview of an object, rather than providing a full display of its contents. Changing the `depth` default to infinity fundamentally changed the role that `util.inspect()` plays, and makes output much more verbose and thus at times unusable for `console.log()`-style debugging. PR-URL: https://github.com/nodejs/node/pull/20017 Fixes: https://github.com/nodejs/node/issues/19405 Refs: https://github.com/nodejs/node/pull/17907 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-05-11Revert "util: change %o depth default"Anna Henningsen
This reverts commit 8f153092d86b0605af8a2ef294dc310fefa83e30. PR-URL: https://github.com/nodejs/node/pull/20017 Refs: https://github.com/nodejs/node/pull/17907 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-05-03util: named anonymous functionsCarrie Coxwell
PR-URL: https://github.com/nodejs/node/pull/20408 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Matheus Marchini <matheus@sthima.com>
2018-04-20util: improve inspect performanceRuben Bridgewater
This improves a slow code part in `util.inspect` by directly retrieving the `Symbol.toStringTag` and by optimizing some code paths. PR-URL: https://github.com/nodejs/node/pull/20009 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@hiroppy.me> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-16util: fix inspect performance bugRuben Bridgewater
In case an object contained a circular reference `Object.keys` was called even though it was not necessary at all. This caused a significant overhead for objects that contained a lot of such entries. PR-URL: https://github.com/nodejs/node/pull/20007 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-04-14util: inspect arguments properlyRuben Bridgewater
Right now it is not possible to distinguish arguments from a regular object. This adds a arguments indicator. PR-URL: https://github.com/nodejs/node/pull/19467 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-12util: introduce `formatWithOptions()`Anna Henningsen
Identical to `format()` except that it takes an options argument that is passed through to `inspect()`. PR-URL: https://github.com/nodejs/node/pull/19372 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-01tools: add 'spaced-comment' into eslint rulesWeijia Wang
PR-URL: https://github.com/nodejs/node/pull/19596 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2018-03-25util: show Weak(Set|Map) entries in inspectRuben Bridgewater
This adds support for WeakMap and WeakSet entries in `util.inspect`. The output is limited to a maximum entry length of `maxArrayLength`. PR-URL: https://github.com/nodejs/node/pull/19259 Fixes: https://github.com/nodejs/node/issues/19001: Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25util: improve iterator inspect outputRuben Bridgewater
1) So far extra keys on an (Set|Map)Iterator were ignored. Those will now be visible. 2) Improve the performance of showing (Set|Map)Iterator by using the cloned iterator instead of copying all entries first. 3) So far the output was strictly limited to up to 100 entries. The limit will now depend on `maxArrayLength` instead (that default is set to 100 as well) and the output indicates that more entries exist than visible. PR-URL: https://github.com/nodejs/node/pull/19259 Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2018-03-25lib: always show ERR_INVALID_ARG_TYPE received partRuben Bridgewater
This makes a effort to make sure all of these errors will actually also show the received input. On top of that it refactors a few tests for better maintainability. It will also change the returned type to always be a simple typeof instead of special handling null. PR-URL: https://github.com/nodejs/node/pull/19445 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-03-17Revert "util: use blue on non-windows systems for number/bigint"Ruben Bridgewater
This reverts commit 1708af369ba4cdfbc9f3eadd657508498b8489a3. Numbers are much more difficult to read in blue and it would be good to have a consistent output throughout all OS. PR-URL: https://github.com/nodejs/node/pull/19256 Refs: https://github.com/nodejs/node/pull/18925 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2018-03-17util: add boxed BigInt formatting to util.inspectMichaël Zasso
Before: > Object(7n) BigInt {} After: > Object(7n) [BigInt: 7n] PR-URL: https://github.com/nodejs/node/pull/19341 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2018-03-15src: put bootstrappers in lib/internal/bootstrap/Joyee Cheung
Create `lib/internal/bootstrap/` and put bootstrappers there: Before: ``` lib/internal ├── ... ├── bootstrap_loaders.js └── bootstrap_node.js ``` After: ``` lib/internal ├── ... └── bootstrap ├── loaders.js └── node.js ``` PR-URL: https://github.com/nodejs/node/pull/19177 Refs: https://github.com/nodejs/node/pull/19112 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2018-03-06src: move internal loaders out of bootstrap_node.jsJoyee Cheung
- Moves the creation of `process.binding()`, `process._linkedBinding()` `internalBinding()` and `NativeModule` into a separate file `lib/internal/bootstrap_loaders.js`, and documents them there. This file will be compiled and run before `bootstrap_node.js`, which means we now bootstrap the internal module & binding system before actually bootstrapping Node.js. - Rename the special ID that can be used to require `NativeModule` as `internal/bootstrap_loaders` since it is setup there. Also put `internalBinding` in the object exported by `NativeModule.require` instead of putting it inside the `NativeModule.wrapper` - Use the original `getBinding()` to get the source code of native modules instead of getting it from `process.binding('native')` so that users cannot fake native modules by modifying the binding object. - Names the bootstrapping functions so their names show up in the stack trace. PR-URL: https://github.com/nodejs/node/pull/19112 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
2018-03-05lib: port errors to new systemMichaël Zasso
This is a first batch of updates that touches non-underscored modules in lib. PR-URL: https://github.com/nodejs/node/pull/19034 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2018-03-05util: introduce `util.types.is[…]` type checksAnna Henningsen
Provide public APIs for native typechecking that is actually useful. The motivation for this is providing alternatives to userland modules that would currently rely on `process.binding('util')`. PR-URL: https://github.com/nodejs/node/pull/18415 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2018-02-25util: use blue on non-windows systems for number/bigintGus Caplan
PR-URL: https://github.com/nodejs/node/pull/18925 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2018-02-22src: replace var for (let|const) in utilities modulejvelezpo
Update Utilities module to replace var for let or const PR-URL: https://github.com/nodejs/node/pull/18814 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matheus Marchini <matheus@sthima.com>
2018-02-20lint: move eslint to new plugin systemGus Caplan
PR-URL: https://github.com/nodejs/node/pull/18566 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
2018-02-07errors: move error creation helpers to errors.jsJoyee Cheung
This commit moves error creation helpers scattered around under lib/ into lib/internal/errors.js in the hope of being clearer about the differences of errors that we throw into the user land. - Move util._errnoException and util._exceptionWithHostPort into internal/errors.js and simplify their logic so it's clearer what the properties these helpers create. - Move the errnoException helper in dns.js to internal/errors.js into internal/errors.js and rename it to dnsException. Simplify it's logic so it no longer calls errnoException and skips the unnecessary argument checks. PR-URL: https://github.com/nodejs/node/pull/18546 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-07util: skip type checks in internal getSystemErrorNameJoyee Cheung
PR-URL: https://github.com/nodejs/node/pull/18546 Reviewed-By: James M Snell <jasnell@gmail.com>
2018-02-01util: add bigint formatting to util.inspectGus Caplan
PR-URL: https://github.com/nodejs/node/pull/18412 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-01-24lib: add internal removeColors helperRuben Bridgewater
Instead of having three times the same RegExp, just use a helper. PR-URL: https://github.com/nodejs/node/pull/17615 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2018-01-20util: implement util.getSystemErrorName()Joyee Cheung
Reimplement uv.errname() as internal/util.getSystemErrorName() to avoid the memory leaks caused by unknown error codes and avoid calling into C++ for the error names. Also expose it as a public API for external use. PR-URL: https://github.com/nodejs/node/pull/18186 Refs: http://docs.libuv.org/en/v1.x/errors.html#c.uv_err_name Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-01-16util: change %o depth defaultRuben Bridgewater
Since the default for depth is changed to `Infinity` it is logical to change the %o default to the same as well. Using %o with `util.format` will now always print the whole object. PR-URL: https://github.com/nodejs/node/pull/17907 Refs: https://github.com/nodejs/node/issues/12693 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-01-16util: change util.inspect depth defaultRuben Bridgewater
The current default is not ideal in most use cases. Therefore it is changed to showing unlimited depth in case util.inspect is called directly. The default is kept as before for console.log and similar. Using console.dir will now show a depth of up to five and console.assert / console.trace will show a unlimited depth. PR-URL: https://github.com/nodejs/node/pull/17907 Refs: https://github.com/nodejs/node/issues/12693 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-12-29util: improve error message of _errnoExceptionWeijia Wang
The usage of ERR_INVALID_ARG_TYPE in _errnoException is a little inappropriate. This change is to improve it. PR-URL: https://github.com/nodejs/node/pull/17626 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-12-28repl: fix coloring of `process.versions`Ben Noordhuis
Remove the custom formatter that was added in commit 4fb27d4 ("intl: Add more versions from ICU"). It's not necessary anymore (and may not have been necessary at all) and prevents proper coloring in the REPL. PR-URL: https://github.com/nodejs/node/pull/17861 Fixes: https://github.com/nodejs/node/issues/17086 Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-21util: rename util.inspect argumentRuben Bridgewater
util.inspect can actually receive any property and the description was wrong so far. This fixes it by renaming the argument to value and also updating the description. PR-URL: https://github.com/nodejs/node/pull/17576 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-21util: add util.inspect compact optionRuben Bridgewater
The current default formatting is not ideal and this improves the situation by formatting the output more intuitiv. 1) All object keys are now indented by 2 characters instead of sometimes 2 and sometimes 3 characters. 2) Each object key will now use an individual line instead of sharing a line potentially with multiple object keys. 3) Long strings will now be split into multiple lines in case they exceed the "lineBreak" option length (including the current indentation). 4) Opening braces are now directly behind a object property instead of using a new line. 5) Switch inspect "base" order. In case the compact option is set to `false`, inspect will now print "[Function: foo] {\n property: 'data'\n}" instead of "{ [Function: foo]\n property: 'data'\n}". PR-URL: https://github.com/nodejs/node/pull/17576 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-15util: allow wildcards in NODE_DEBUG variableTyler
PR-URL: https://github.com/nodejs/node/pull/17609 Fixes: https://github.com/nodejs/node/issues/17605 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-12-09util: fix negative 0 check in inspectGus Caplan
PR-URL: https://github.com/nodejs/node/pull/17507 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-01util: use @@toStringTagGus Caplan
uses @@toStringTag when creating the "tag" for an inspected value PR-URL: https://github.com/nodejs/node/pull/16956 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>