Ruben Bridgewater
575784b4cf
assert,util: revert recursive breaking change
...
This commit is there to be reverted after merging. It makes it easy
to backport the overall PR and allows easy forward fixing.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46593
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-02-20 15:47:08 +01:00
Ruben Bridgewater
449e9f4489
assert,util: improve deep equal comparison performance
...
This is mainly a performance improvement for a lot of simple cases.
Diverging elements are detected earlier and equal entries are
partially also detected faster.
A small correctness patch is also included where recursions now
stop as soon as either side has a circular structure. Before, both
sides had to have a circular structure at the specific comparison
which could have caused more checks that likely fail at a later
point.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46593
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-02-20 15:47:06 +01:00
Ruben Bridgewater
a02b434966
test: remove obsolete util.isDeepStrictEqual tests
...
These tests are a copy of the assert tests that verify the
deep equal comparison algorithm. There is no need to duplicate the
tests as changing one would require to change the tests in two
places without knowing which ones to actually rely upon.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46593
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-02-20 15:47:03 +01:00
Ruben Bridgewater
841279d79c
benchmark: rework assert benchmarks for correctness
...
This reworks most assert benchmarks to provide more reliable test
cases that also test more cases than before while keeping the
runtime low.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46593
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2023-02-20 15:46:55 +01:00
Ruben Bridgewater
43c380e9b6
assert: remove deprecated getFunction() usage
...
The method is meant to be removed by the V8 team. It is not a
critical functionality that is removed, therefore no alternative
is checked for either.
Refs: https://bugs.chromium.org/p/v8/issues/detail?id=9421
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46661
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-02-20 10:34:38 +00:00
Ruben Bridgewater
f17a642cf2
os: improve network interface performance
...
This reduces the overhead of getCIDR() to a minimum. No array is
allocated anymore and parts are directly sliced out of the netmask
string instead.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/46598
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2023-02-20 01:25:54 +00:00
Ruben Bridgewater and Shelley Vohr
fbd55a8139
lib: do not crash using workers with disabled shared array buffers
...
This allows the repl to function normally while using the
`--no-harmony-sharedarraybuffer` V8 flag.
It also fixes using workers while using the
`--no-harmony-atomics` V8 flag.
Fixes: https://github.com/nodejs/node/issues/39717
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/41023
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2023-02-18 11:18:04 +01:00
Ruben Bridgewater
d3dd49fe2b
fs: improve promise based readFile performance for big files
...
This significantly reduces the peak memory for the promise
based readFile operation by reusing a single memory chunk after
each read and strinigifying that chunk immediately.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/44295
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2022-10-06 17:03:56 +00:00
Ruben Bridgewater
7cfd5f169c
util: remove unnecessary template string
...
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41082
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-07-09 15:46:39 +00:00
Ruben Bridgewater
b5cb3410e0
util: mark cwd grey while inspecting errors
...
This changes the util.inspect() output for errors in case stack
traces contain the current working directory in their trace.
If that's the case, the cwd part is marked grey to focus on the
rest of the path.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41082
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2022-07-09 15:46:38 +00:00
Ruben Bridgewater
54e9cba336
util: do not reduce to a single line if not appropriate using inspect
...
This makes sure entries are not lined up on a single line if the
content contains any new line. That would otherwise cause confusing
output.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41083
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-12-24 07:32:59 -08:00
Ruben Bridgewater
c2ff69db4c
util: serialize falsy cause values while inspecting errors
...
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41097
Fixes: https://github.com/nodejs/node/issues/41096
Reviewed-By: Michaël Zasso <targos@protonmail.com >
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 >
2021-12-11 12:05:41 +00:00
Ruben Bridgewater
1133796dbf
util: make sure error causes of any type may be inspected
...
An error cause may be of any type. Handle all of them, no matter
if they are an error or not.
Fixes: https://github.com/nodejs/node/issues/41096
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41097
Reviewed-By: Michaël Zasso <targos@protonmail.com >
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 >
2021-12-11 12:05:41 +00:00
Ruben Bridgewater
4569674e39
util: pass through the inspect function to custom inspect functions
...
This allows to use more portable custom inspect functions.
Fixes: https://github.com/nodejs/node/issues/35956
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41019
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-12-11 11:49:45 +00:00
Ruben Bridgewater
414bc7bec1
assert: use stricter stack frame detection in .ifError()
...
This makes sure arbitrary stack traces are not handled as stack
frames.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41006
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-12-06 17:38:26 +00:00
Ruben Bridgewater
76372607a6
util: escape lone surrogate code points using .inspect()
...
Unpaired surrogate code points have no representation in UTF8.
Therefore, such code points are just "random" output that is
unreadable. Instead, escape the code points similar to C0 and C1
control characters.
Refs: https://unicodebook.readthedocs.io/unicode_encodings.html#utf-16-surrogate-pairs
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41001
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-12-06 17:38:15 +00:00
Ruben Bridgewater
85764c0e1a
util: add numericSeparator to util.inspect
...
This adds the `numericSeparator` option to util.inspect. Using it
separates numbers by thousands adding the underscore accordingly.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41003
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-12-03 14:56:43 +00:00
Ruben Bridgewater
dab8ab2837
assert,util: compare RegExp.lastIndex while using deep equal checks
...
Compare the `lastIndex` property of regular expressions next to the
flags and source property.
Fixes: https://github.com/nodejs/node/issues/28766
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41020
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
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 >
2021-12-02 08:01:40 +00:00
Ruben Bridgewater
9121bb301f
lib: do not lazy load EOL in blob
...
This addresses a comment by loading the EOL from the constants file.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41004
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2021-12-02 06:02:01 +00:00
Ruben Bridgewater
0a9cb170fe
util: always visualize cause property in errors during inspection
...
While inspecting errors, always visualize the cause. That property
is non-enumerable by default while being useful in general for
debugging.
Duplicated stack frames are hidden.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41002
Fixes: https://github.com/nodejs/node/issues/40859
Fixes: https://github.com/nodejs/node/issues/38725
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-12-02 06:01:50 +00:00
Ruben Bridgewater
bbed2a77d3
readline: skip escaping characters again
...
This is a minor performance improvement for readline. It skips to
escape individual characters again after escaping them before.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/41005
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-12-01 01:50:34 +00:00
Ruben Bridgewater
5bfb6f0564
doc: fix outdated util inspect documentation and layout example
...
The documentation and layout example was not up to date with the
latest changes.
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:50 -07:00
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
Ruben Bridgewater
5ff2e582cd
assert,util: fix commutativity edge case
...
Verify that both objects property keys are enumerable.
Fixes: https://github.com/nodejs/node/issues/37710
PR-URL: https://github.com/nodejs/node/pull/37711
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2021-03-13 13:44:06 +01: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
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
Ruben Bridgewater
b831b081c4
repl: always check for NODE_REPL_MODE environment variable
...
This makes sure all REPL instances check for the NODE_REPL_MODE
environment variable in case the `replMode` is not passed through
as option.
At the same time this simplifies the internal REPL code significantly.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33461
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-06-25 11:54:46 -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
Ruben Bridgewater
f7626866d5
doc: outline when origin is set to unhandledRejection
...
The `uncaughtException` listener's origin argument was ambiguous
about unhandled rejections. This should clarify when origin is set
to `'unhandledRejection'`.
Fixes: https://github.com/nodejs/node/issues/32907
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33530
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 04:21:21 +02:00
Ruben Bridgewater
4bdab881b8
console: name console functions appropriately
...
The current name of most of the global console functions is
"bound consoleCall". This is changed to the actual functions name
e.g., "log" or "error".
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33524
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-05-30 04:19:27 +02:00
Ruben Bridgewater
87629d7e7c
console: mark special console properties as non-enumerable
...
This makes sure internal console properties are not visible during
default inspection. They are still visible when inspecting the
console with `showHidden` set to `true`.
These properties are confusing while working with the REPL and easily
show up.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33524
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-05-30 04:19:18 +02:00
Ruben Bridgewater
b61249e32d
console: remove dead code
...
This check is always truthy. Thus, it's removed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33524
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-05-30 04:19:14 +02:00
Ruben Bridgewater
6cc94b2d7f
errors: fully inspect errors on exit
...
This makes sure errors are fully inspected during exit. That is
important to provide as many debugging information to the user as
possible.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33523
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 04:18:16 +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
49745cdef0
process: delay throwing an error using throwDeprecation
...
This makes sure all warnings that were triggered before a deprecation
warning during the same tick are properly handled and logged.
It also guarantees that users can not catch the error anymore.
Fixes: https://github.com/nodejs/node/issues/17871
PR-URL: https://github.com/nodejs/node/pull/32312
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-23 21:48:27 +02:00
Ruben Bridgewater
1acc14baf9
repl: add builtinModules
...
This adds an alias to `_builtinLibs` that is documented and should
as such also be accessed publicly. It does not contain any
underscored modules.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33295
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-23 15:37:02 +02:00
Ruben Bridgewater
a416692e93
repl: remove deprecated repl.memory function
...
This removes the memory function. It is deprecated for a long time
while not being really helpful being exposed. Thus, it is removed
to improve maintainability of the REPL module.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33286
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-23 03:12:06 +02:00
Ruben Bridgewater
f217b2dfb0
repl: remove deprecated repl.turnOffEditorMode() function
...
This function is deprecated for multiple years and provides very
little benefit to users. Thus, it's removed to improve the
maintainability of the REPL module.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33286
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-23 03:12:06 +02:00
Ruben Bridgewater
a1bcad8dc0
repl: remove deprecated repl.parseREPLKeyword() function
...
This removes the deprecated REPLServer.parseREPLKeyword function. It
is deprecated for a long time and should not provide any benefit to
users. To improve the maintainability of the REPL module, it's now
removed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33286
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-23 03:12:05 +02:00
Ruben Bridgewater
4ace010b53
repl: remove deprecated bufferedCommand property
...
This property is deprecated since Node.js v9.0.0 and to improve
maintainability of the REPL it is now removed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33286
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-23 03:12:05 +02:00
Ruben Bridgewater
37524307fe
repl: remove deprecated .rli
...
The .rli property is just a reference to the active REPL instance
and it was deprecated for a long time.
To improve maintainability of the REPL this feature is removed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33286
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-23 03:12:05 +02:00
Ruben Bridgewater
19d9e2003e
repl: simplify repl autocompletion
...
This refactors the repl autocompletion code for simplicity and
readability.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33450
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-05-20 17:31:47 +02:00
Ruben Bridgewater
76c5dc995e
repl: support optional chaining during autocompletion
...
This makes sure the autocompletion is able to handle optional
chaining notations.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33450
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2020-05-20 17:31:47 +02:00
Ruben Bridgewater
9de08f773e
lib: update TODO comments
...
This removes one TODO comment and adds another that indicates that
readline is currently not able to trigger specific escape sequences.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33361
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-05-20 17:05:06 +02:00
Ruben Bridgewater
da7be6979e
doc: fix readline key binding documentation
...
The documentation for two key bindings was not correct.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33361
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
2020-05-20 17:05:01 +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
Ruben Bridgewater
ab7d5200cd
repl: deprecate repl._builtinLibs
...
This is a manually edited and outdated list of builtin modules.
Instead, it is better to rely upon the officially documented way
to get a list of builtin modules.
As a side by fix this makes sure all exports are in one place. Thus,
it is easier to see what parts are actually exported and which are
not.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33294
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-16 10:54:07 +02:00
Ruben Bridgewater
ee176f1205
repl: remove obsolete completer variable
...
It is also assigned in readline. There is not need to assign the
variable twice.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33294
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-16 10:53:58 +02:00
Ruben Bridgewater
e11b5d3d7d
repl: deprecate repl.inputStream and repl.outputStream
...
The stream is exposed twice. As such it's best to rely upon the
.input and .output properties set by readline.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33294
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-16 10:53:54 +02:00
Ruben Bridgewater
24bf1adacc
module: do not check circular dependencies for exported proxies
...
In case the exported module is a proxy that has the `getPrototypeOf`
or `setPrototypeOf` trap, skip the circular dependencies check.
It would otherwise be triggered by the check itself.
Fixes: https://github.com/nodejs/node/issues/33334
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33338
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Zeyu Yang <himself65@outlook.com >
2020-05-15 01:55:28 +02:00
Ruben Bridgewater
50ba066921
repl: improve repl autocompletion for require calls
...
This improves the autocompletion for require calls. It had multiple
small issues so far. Most important: it won't suggest completions for
require statements that are fully written out. Second, it'll detect
require calls that have whitespace behind the opening bracket. Third,
it makes sure node modules are detected as such instead of only
suggesting them as folders. Last, it adds suggestions for input that
starts with backticks.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Fixes: https://github.com/nodejs/node/issues/33238
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:40 +02:00
Ruben Bridgewater
4fa7d6e4c4
test: refactor test/parallel/test-bootstrap-modules.js
...
This simplifies the test a bit by removing duplicated code and by
focusing the reader on the passed through module.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:21 +02:00
Ruben Bridgewater
900daedbfe
repl: replace hard coded core module list with actual list
...
This replaces the internally used hard coded Node.js core module
list with the actual internal existent modules. That way all modules
are automatically picked up instead of having to update the list
manually.
This currently only applies to the REPL and to the Node.js `eval`
functionality (User passed `-e` or `--eval` arguments to Node without
`-i` or `--interactive`).
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:17 +02:00
Ruben Bridgewater
b38d26a168
repl: show reference errors during preview
...
This aligns the behavior with the one in the Firefox console.
It will visualize ReferenceErrors in case the input has no possible
completion and no buffered input. That way typos can already be
highlighted before being evaluated.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:13 +02:00
Ruben Bridgewater
80913e655f
repl: improve repl preview
...
This aligns the REPL preview with the one used in the Chrome
DevTools console. It will now preview the output for the input
including the completion suffix as input. When pressing enter while
previewing such data, it will automatically insert the suffix
before evaluating the input. When pressing escape, that behavior
is deactivated until the input is changed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:08 +02:00
Ruben Bridgewater
18584727de
tools: remove obsolete no-restricted-syntax eslint rules
...
These rules only apply for the test folder and will already be
checked for.
PR-URL: https://github.com/nodejs/node/pull/32161
Refs: https://github.com/nodejs/node/pull/32078
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-10 14:00:44 +02:00
Ruben Bridgewater
36b2e25b4a
tools: add eslint rule to only pass through 'test' to debuglog
...
This makes sure all usages of `util.debuglog()` must contain the
string 'test' as argument.
PR-URL: https://github.com/nodejs/node/pull/32161
Refs: https://github.com/nodejs/node/pull/32078
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-10 14:00:37 +02:00
Ruben Bridgewater
c81e5f699e
doc: mark assert.CallTracker experimental
...
Some details might still change and it would be good to get feedback
from users before we mark this as stable.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33124
Reviewed-By: Zeyu Yang <himself65@outlook.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-04 14:59:32 +02:00
Ruben Bridgewater
d7b02c3cad
2020-04-29, Version 13.14.0 (Current)
...
Notable Changes:
* async_hooks**:
* Merge `run` and `exit` methods (Andrey Pechkurov)
https://github.com/nodejs/node/pull/31950
* Prevent sync methods of async storage exiting outer context
(Stephen Belanger)
https://github.com/nodejs/node/pull/31950
* vm:
* Add `importModuleDynamically` option to compileFunction (Gus
Caplan)
https://github.com/nodejs/node/pull/32985
New core collaborators:
With this release, we welcome two new Node.js core collaborators:
* Juan José Arboleda @juanarbol
https://github.com/nodejs/node/pull/32906
* Andrey Pechkurov @puzpuzpuz
https://github.com/nodejs/node/pull/32817
PR-URL: https://github.com/nodejs/node/pull/33122
2020-04-30 00:24:31 +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
Ruben Bridgewater
08c656bb7b
deps: update acorn to v7.1.1
...
Also clean up the plugins package.json files.
PR-URL: https://github.com/nodejs/node/pull/32310
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-03-29 22:43:15 +02:00
Ruben Bridgewater
e322f74ce1
test: refactor and simplify test-repl-preview
...
Use an object to indicate which part belongs to the input and which
to the output.
On top of that this also simplifies the expected output by
automatically inserting the default repl line for previews and by
automatically checking for the correct output line length.
PR-URL: https://github.com/nodejs/node/pull/32154
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-13 09:58:13 +01:00
Ruben Bridgewater
9c18ff6440
repl: align preview with the actual executed code
...
This adds preview output for input that may not be wrapped.
PR-URL: https://github.com/nodejs/node/pull/32154
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-13 09:58:12 +01:00
Ruben Bridgewater
bb6125bac7
benchmark: remove special test entries
...
This reverts commit 7cfbc9f90f .
PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-03-09 22:35:54 +01:00
Ruben Bridgewater
9e40df763b
test: refactor all benchmark tests to use the new test option
...
This reverts commit aa0a01bd36 .
PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-03-09 22:35:54 +01:00
Ruben Bridgewater
1760c23f75
benchmark: add test and all options and improve errors"
...
This reverts commit 4671d551cf and
contains a fix to the issue raised for the revert.
PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-03-09 22:35:53 +01:00
Ruben Bridgewater
f64aafa2d5
benchmark: refactor helper into a class
...
This reverts commit 5b0308cd82 .
PR-URL: https://github.com/nodejs/node/pull/31755
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-03-09 22:35:53 +01:00
Ruben Bridgewater
41ac192192
test: increase test timeout to prevent flakiness
...
This increases the waiting time for each event from 500 to 750 ms.
The former timeout could be hit on very slow machines with high load.
PR-URL: https://github.com/nodejs/node/pull/31716
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-03-09 14:22:38 +01:00
Ruben Bridgewater
9da57a86ee
test: fix flaky parallel/test-repl-history-navigation test
...
Two scenarios should be tested:
1. The completion is triggered and the result is printed before the
next invocation.
2. The completion is triggered multiple times right after each other
without waiting for the result. In that case only the last result
should be printed.
The first scenario did not need a timeout while the latter did not
need a timeout for the second invocation.
PR-URL: https://github.com/nodejs/node/pull/31708
Fixes: https://github.com/nodejs/node/issues/31094
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-02-13 21:18:30 +01:00
Ruben Bridgewater
63f10b9f0d
tty: do not end in an infinite warning recursion
...
It was possible that this warning ends up in an infinite recursion.
The reason is that printing the warning triggered a color check and
that triggered another warning. Limiting it to a single warning
prevents this.
PR-URL: https://github.com/nodejs/node/pull/31429
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-02-09 13:39:56 +01:00
Ruben Bridgewater
0f6fed4f07
test: stricter assert color test
...
Make sure the assertion is actually triggered by using
`assert.throws()` instead of `try/catch`.
PR-URL: https://github.com/nodejs/node/pull/31429
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-02-09 13:39:55 +01:00
Ruben Bridgewater
36f328e21f
assert: align character indicators properly
...
This makes sure color codes are not taken into account in case
util.inspect's default value was changed.
PR-URL: https://github.com/nodejs/node/pull/31429
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-02-09 13:39:54 +01:00
Ruben Bridgewater
1450ea7bf6
test: improve logged errors
...
To indicate which lines are test lines and which from Node.js core,
it's good to rely on `util.inspect()` while inspecting errors.
The stack was accessed directly instead in multiple cases and logging
that does not provide as much information as using `util.inspect()`.
PR-URL: https://github.com/nodejs/node/pull/31425
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Yihong Wang <yh.wang@ibm.com >
2020-02-09 13:36:39 +01:00
Ruben Bridgewater
357230f4b7
benchmark: remove special test entries
...
It was necessary to have fallbacks to run the original tests. This
is obsolete with the new test mode.
PR-URL: https://github.com/nodejs/node/pull/31396
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-09 13:32:12 +01:00
Ruben Bridgewater
78aa348f4e
test: refactor all benchmark tests to use the new test option
...
PR-URL: https://github.com/nodejs/node/pull/31396
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-09 13:31:54 +01:00
Ruben Bridgewater
dac579516c
benchmark: add test and all options and improve errors
...
This adds a new `test` option. Using it automatically uses a single
minimal option matrix to verify the benchmark works as expected.
Using the new `all` option makes sure all test suites are run.
On top of that the benchmarks will from now on report properly
what category might have a typo, if any.
The http duration was also refactored to use a option instead of
relying on a configuration setting.
The fixture folder is ignored as test suite from now on.
PR-URL: https://github.com/nodejs/node/pull/31396
Fixes: https://github.com/nodejs/node/issues/31083
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-09 13:31:45 +01:00
Ruben Bridgewater
b70741ea43
benchmark: refactor helper into a class
...
This is the basis to refactor the helper to use modern class
language features such as private fields.
It also refactors the exports to use module.exports. That way it's
immediately clear what parts are exported.
PR-URL: https://github.com/nodejs/node/pull/31396
Reviewed-By: Sam Roberts <vieuxtech@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-09 13:31:38 +01:00
Ruben Bridgewater
f9a27ea510
readline: make tab size configurable
...
This adds the `tabSize` option to readline to allow different tab
sizes.
PR-URL: https://github.com/nodejs/node/pull/31318
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Denys Otrishko <shishugi@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2020-02-07 12:38:04 +01:00
Ruben Bridgewater
1fb4bd1fc4
test: abstract common assertions in readline-interface test
...
PR-URL: https://github.com/nodejs/node/pull/31423
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-05 13:59:54 +01:00
Ruben Bridgewater
f295ba5d2c
test: refactor test-readline-interface.js
...
This reduces the code lines required to run the tests by abstracting
the constructor call. It also moves tests out of a for loop that
where miss placed.
PR-URL: https://github.com/nodejs/node/pull/31423
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-02-05 13:59:52 +01:00
Ruben Bridgewater
fb6df3bfac
fs: validate the input data to be of expected types
...
The input was not validated so far and that caused unwanted side
effects. E.g., `undefined` became the string `'undefined'`. It was
expected to fail or to end up as empty string.
Now all input is validated to be either some type of array buffer
view or a string. That way it's always clear what the user intents.
PR-URL: https://github.com/nodejs/node/pull/31030
Fixes: https://github.com/nodejs/node/issues/31025
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com >
2020-02-05 13:39:53 +01: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
Ruben Bridgewater
c3b702f9b4
repl: do not preview while pasting code
...
This makes sure no previews are triggered while pasting code. The
very last character is allowed to trigger the preview. The output
should be completely identical to the user.
PR-URL: https://github.com/nodejs/node/pull/31315
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2020-01-13 08:59:45 +01:00
Ruben Bridgewater
4455f60320
doc: use shorter fs.copyFile examples
...
This consolidates some examples to concentrate the reader on the
important aspects and to reduce reading overhead.
PR-URL: https://github.com/nodejs/node/pull/27044
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-01-12 20:45:22 +01:00
Ruben Bridgewater
a13500f503
fs: improve mode and flags validation
...
This fixes a few bugs in `fs`. E.g., `fs.promises.access` accepted
strings as mode. It should have only accepted numbers. It will now
always validate the flags and the mode argument in an consistent way.
PR-URL: https://github.com/nodejs/node/pull/27044
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-01-12 20:45:21 +01:00
Ruben Bridgewater
a45c1aa39f
doc: fix mode and flags being mistaken in fs
...
Multiple `fs` functions have a `mode` and or `flag` option. In some
cases those have been mistaken and named wrongly. All of those faulty
entries have been fixed.
Besides that some indentation is also aligned with the rest of the
document.
PR-URL: https://github.com/nodejs/node/pull/27044
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
2020-01-12 20:45:20 +01:00
Ruben Bridgewater
af5ddf2123
repl: fix preview cursor position
...
The cusor position was off in case the preview was exactly as long
as the current terminal was wide.
PR-URL: https://github.com/nodejs/node/pull/31293
Fixes: https://github.com/nodejs/node/issues/31291
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-12 20:43:12 +01:00
Ruben Bridgewater
79524673c0
test: stricten readline keypress failure test condition
...
This verifies that the thrown error is the expected one. That was
not tested before.
PR-URL: https://github.com/nodejs/node/pull/31300
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-12 20:40:10 +01:00
Ruben Bridgewater
fe058188a1
repl,readline: clean up code
...
This simplifies code that was more complicated than it had to be
and removes code that should never be reached.
PR-URL: https://github.com/nodejs/node/pull/31288
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-11 14:06:45 -08:00
Ruben Bridgewater
5baae143c7
readline: improve unicode support and tab completion
...
1. This reduces the number of write operations used during tab
completion.
2. The tab completion calculated the string width using the length
of the string instead of using the actual width. That is fixed.
3. The key decoder is now capable of handling characters composed
out of two code points. That reduces the number of "keypress"
events that are emitted which again lowers the amount of writes
triggered.
PR-URL: https://github.com/nodejs/node/pull/31288
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-11 14:06:33 -08:00
Ruben Bridgewater
95303629a4
repl: change preview default in case of custom eval functions
...
Custom eval functions might have a very different behavior than the
current implementation and having a preview in such case might be
confusing. This changes the preview default to `false` in case a
custom eval function is used. It is still possible to opt into using
the previews in case that's still desirable.
PR-URL: https://github.com/nodejs/node/pull/31259
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-10 04:35:37 -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
Ruben Bridgewater
84c3b87494
test: add repl tests to verify unicode support in previews
...
This also adds a test to verify that changed writer options also
change the preview output depending on the options.
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:57 +01:00
Ruben Bridgewater
5235394e66
repl: activate previews for lines exceeding the terminal columns
...
This improves the completion previews by activating them for lines
that exceed the current terminal columns.
As a drive-by fix it also simplifies some statements.
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:56 +01:00
Ruben Bridgewater
092e8426ab
readline,repl: support tabs properly
...
PR-URL: https://github.com/nodejs/node/pull/31112
Fixes: https://github.com/nodejs/node/issues/25272
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-10 09:11:55 +01:00
Ruben Bridgewater
0da2084d7f
src: change GetStringWidth's expand_emoji_sequence option default
...
The option is now set to true by default. Most terminals do not have
full emoji support and visualize emojis with zero width joiners as
individual emojis.
Also verify that at least one argument is always passed through to the
function and remove support for passing through code points. Only
accept strings from now on to simplify the API.
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:54 +01:00