Commit Graph

148 Commits

Author SHA1 Message Date
Ruben Bridgewater
942b76d9e5
util: fix infinite recursion during inspection
A specially crafted object with circular structures behind getters
could cause a infinite recursion. This is now fixed by detecting the
objects as already visited.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/37079
Fixes: https://github.com/nodejs/node/issues/37054
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2021-04-30 12:46:48 -07:00
Antoine du Hamel
d756d2b99c lib: enforce using primordials.globalThis instead of global
PR-URL: https://github.com/nodejs/node/pull/38230
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-04-17 15:30:58 +02:00
Rich Trott
038608d401 tools: relax max-len lint rule for template strings
Splitting template strings across multiple lines can make them harder to
read.

PR-URL: https://github.com/nodejs/node/pull/38097
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-07 04:16:35 -07:00
Rich Trott
45cdc134cd util: remove unreachable inspect code
Convert invariant from if statement to an assertion. The condition is
believed to be impossible to trigger.

PR-URL: https://github.com/nodejs/node/pull/37941
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-03-28 21:42:41 -07:00
Anna Henningsen
7296bcb3cb util: inspect __proto__ key as written in object literal
Since util.inspect() gives object-literal-like output, handle the
special `__proto__` key in the way that it would be handled in object
literals.

PR-URL: https://github.com/nodejs/node/pull/37713
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2021-03-13 20:38:26 +01:00
Luigi Pinca
e84e6e7fad stream,util: fix "the the" typo in comments
PR-URL: https://github.com/nodejs/node/pull/37674
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2021-03-13 10:01:19 +01:00
Antoine du Hamel
f34d8de65a lib: remove use of array destructuring
PR-URL: https://github.com/nodejs/node/pull/36818
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-03-03 19:53:24 +01:00
Rich Trott
b461a1b125 doc,lib: prepare for stricter multi-line array linting
We're about to turn on a requirement for dangling commas.

PR-URL: https://github.com/nodejs/node/pull/37088
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-02-19 09:55:35 -08:00
Rich Trott
04bef7aabd util: use assert for unreachable code
Great effort is taken to keep `util.inspect()` from throwing while
inspecting a linked list or other items that require recursion. It is
likely still possible at this time to cause a throw with prototype
pollution, but that will change soon when the code is modified to use
primordials.

This commit instructs our coverage to not be concerned about not being
able to reach the throwing-an-error code and changes the throw there to
an assert so users will be instructed to open a bug with Node.js should
they manage to cause the code to throw.

PR-URL: https://github.com/nodejs/node/pull/37249
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2021-02-08 09:52:58 -08:00
ExE Boss
728fee22e9 lib: add bound apply variants of varargs primordials
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37005
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-28 18:45:43 +01:00
ZiJian Liu
029d1fd797 lib: refactor to use validateObject
Co-authored-by: ExE Boss <3889017+ExE-Boss@users.noreply.github.com>
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/37028
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-28 12:53:50 +01:00
ExE Boss
e9944e9a38 util: prefer Reflect.ownKeys(…)
PR-URL: https://github.com/nodejs/node/pull/36740
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-01-20 01:25:17 +01:00
raisinten
9a18bf2f8c
repl: refactor to avoid unsafe array iteration
PR-URL: https://github.com/nodejs/node/pull/36663
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-01-18 13:29:43 -08:00
Rohan Chougule
779f1bbd74 util: refactor inspect.js to use more primodials
PR-URL: https://github.com/nodejs/node/pull/36730
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Pooja D P <Pooja.D.P@ibm.com>
2021-01-05 19:47:45 +01:00
Antoine du Hamel
ecdff81684 util: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36265
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2020-12-28 19:47:41 +00:00
Antoine du Hamel
bd6f2303f4 lib: add primordials.SafeStringIterator
PR-URL: https://github.com/nodejs/node/pull/36526
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-12-25 18:11:23 +00:00
Rich Trott
f43d1ca3b0 util: simplify constructor retrieval in inspect()
Instead of looping through a list of typed arrays, use
TypedArrayPrototypeGetSymbolToStringTag.

PR-URL: https://github.com/nodejs/node/pull/36466
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-14 05:42:06 -08:00
Ruben Bridgewater
1e665095c8 util: fix instanceof checks with null prototypes during inspection
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: https://github.com/nodejs/node/issues/35730

PR-URL: https://github.com/nodejs/node/pull/36178
Fixes: https://github.com/nodejs/node/issues/36151
Refs: https://github.com/nodejs/node/pull/35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-12 20:58:02 +00:00
Ruben Bridgewater
f78da00ab7 util: fix module prefixes during inspection
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

Fixes: https://github.com/nodejs/node/issues/36151

PR-URL: https://github.com/nodejs/node/pull/36178
Fixes: https://github.com/nodejs/node/issues/35730
Refs: https://github.com/nodejs/node/pull/35754
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-12 20:58:01 +00:00
ExE Boss
c83e599420
lib: add uncurried accessor properties to primordials
Closes: https://github.com/nodejs/node/pull/32127

PR-URL: https://github.com/nodejs/node/pull/36329
Fixes: https://github.com/nodejs/node/issues/32127
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-12-07 10:02:34 -08:00
raisinten
929c51f14a util: fix to inspect getters that access this
Fixes: https://github.com/nodejs/node/issues/36045

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36052
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-12 05:39:43 -08:00
ExE Boss
c925e24ae7 lib: add %TypedArray% abstract constructor to primordials
Refs: https://github.com/nodejs/node/pull/35448
Refs: https://github.com/nodejs/node/pull/36003
Refs: https://tc39.es/ecma262/#sec-%typedarray%-intrinsic-object

Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36016
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-11-09 09:41:14 +00:00
Michaël Zasso
21782277c2
src: use node:moduleName as builtin module filename
This change allows for easier recognition of builtin modules in stack
traces.

Refs: https://github.com/nodejs/node/issues/11893

PR-URL: https://github.com/nodejs/node/pull/35498
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
2020-10-07 17:35:14 +02:00
Michaël Zasso
1469984645 lib: use remaining typed arrays from primordials
PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-10-07 13:44:21 +00:00
Michaël Zasso
070873649c lib: use Number.parseFloat from primordials
PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-10-07 13:44:21 +00:00
Michaël Zasso
a073f532da lib: use Number.parseInt from primordials
PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-10-07 13:44:20 +00:00
Sebastien Ahkrin
b79829c5f5
lib: replace String global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:56 +02:00
Sebastien Ahkrin
693cc2c1c3
lib: replace Int8Array global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:54 +02:00
Sebastien Ahkrin
6883c8d30b
lib: replace Int32Array global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:52 +02:00
Sebastien Ahkrin
34b7b47849
lib: replace Float64Array global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:51 +02:00
unknown
fe2a7f052f
util: print External address from inspect
Fixes: https://github.com/nodejs/node/issues/28250

PR-URL: https://github.com/nodejs/node/pull/34398
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2020-07-28 14:30:52 +02:00
Ruben Bridgewater
2e82982984
util: improve getStringWidth performance
This makes sure the common path does not normalize the input string.
It's only required for characters that are outside of the ASCII range.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2020-07-20 18:17:06 +02:00
sapics
ee3416b055 lib: replace http to https of comment link urls
PR-URL: https://github.com/nodejs/node/pull/34158
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-07-06 07:03:08 -07:00
Ruben Bridgewater
3646872f60
util: fix width detection for DEL without ICU
This makes sure the DEL character (ASCII 127) is detected as a zero
width character even if Node.js is not built with ICU.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-06-25 06:42:38 -07:00
Ruben Bridgewater
66679ce334
util: support Combining Diacritical Marks for Symbols
This adds support for the "Combining Diacritical Marks for Symbols"
unicode group to calculate a zero length width even if Node.js is
built without ICU.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33650
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2020-06-25 06:42:34 -07:00
Ruben Bridgewater
2c4864762d
util: gracefully handle unknown colors
This makes sure colors that are unknown won't cause an error. This
is especially important in case a library wants to use colors
defined by Node.js core, if available and fall back to the default
otherwise.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33797
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-06-19 17:36:21 +02:00
Anna Henningsen
58bae4d0ef
util: restrict custom inspect function + vm.Context interaction
When `util.inspect()` is called on an object with a custom inspect
function, and that object is from a different `vm.Context`,
that function will not receive any arguments that access
context-specific data anymore.

PR-URL: https://github.com/nodejs/node/pull/33690
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-06-11 21:44:34 +02:00
Sebastien Ahkrin
178efdf5a2
lib: add Int16Array primordials
PR-URL: https://github.com/nodejs/node/pull/31205
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2020-06-02 15:38:59 +02:00
Ruben Bridgewater
e24731cb70 util: fix inspection of class instance prototypes
To achieve this, some internal custom inspect functions had to be
changed. They relied upon the former behavior.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/33449
Fixes: https://github.com/nodejs/node/issues/33419
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2020-05-25 19:20:48 +02:00
Ruben Bridgewater
3a5158878b
util: mark classes while inspecting them
This outlines the basic class setup when inspecting a class.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>

PR-URL: https://github.com/nodejs/node/pull/32332
Fixes: https://github.com/nodejs/node/issues/32270
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2020-05-20 12:32:22 +02:00
Anna Henningsen
6068c72ae3
util,readline: NFC-normalize strings before getStringWidth
The assumption here is that decomposed characters render like their
composed character equivalents, and that working with the former
comes with a risk of over-estimating string widths given that
we compute them on a per-code-point basis. The regression test
added here (한글 vs 한글) is an example of that happening.

PR-URL: https://github.com/nodejs/node/pull/33052
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-27 19:45:05 +02:00
unknown
1211b9a72f
util: change default value of maxStringLength to 10000
Refs: https://github.com/nodejs/node/pull/32392

PR-URL: https://github.com/nodejs/node/pull/32744
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-04-13 19:46:35 +02:00
unknown
944d8626b3
util: add maxStrLength option to inspect function
Refs: https://github.com/nodejs/node/issues/25478

PR-URL: https://github.com/nodejs/node/pull/32392
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-04-08 18:02:54 +02:00
Ruben Bridgewater
6baddcfddf
util: only inspect error properties that are not visible otherwise
Inspecting errors results in duplicated information in case an error
is created with enumerable `name`, `message` or `stack` properties.
In that case, check if the output already contains that information
and prevent listing that property.

This reduces the noise as receiver.

PR-URL: https://github.com/nodejs/node/pull/32327
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
2020-04-02 18:41:57 +02:00
Gus Caplan
89ae1f1b73
util: fix inspecting document.all
Fixes: https://github.com/nodejs/node/issues/31889

PR-URL: https://github.com/nodejs/node/pull/31938
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-03-30 10:17:08 +02:00
Ruben Bridgewater
725682cc50 util: fix inspection of typed arrays with unusual length
This makes sure `util.inspect()` does not throw in case the typed
array's length property was set to something invalid. Instead,
always use the original information.

PR-URL: https://github.com/nodejs/node/pull/31458
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-24 21:09:17 -08:00
Ruben Bridgewater
8fb5fe28a4
util: improve unicode support
The array grouping function relies on the width of the characters.
It was not calculated correct so far, since it used the string
length instead.
This improves the unicode output by calculating the mono-spaced
font width (other fonts might differ).

PR-URL: https://github.com/nodejs/node/pull/31319
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2020-01-22 15:33:03 +01:00
Sebastien Ahkrin
a2c4244e3d
lib: replace BigInt64Array global by the primordials
PR-URL: https://github.com/nodejs/node/pull/31193
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-13 12:42:21 +01:00
Sebastien Ahkrin
eca22d5565 lib: add Uint16Array primordials
PR-URL: https://github.com/nodejs/node/pull/31210
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-10 20:27:10 +08:00
Ruben Bridgewater
b0a7621577
util: add todo comments for inspect to add unicode support
PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-01-10 09:11:58 +01:00