diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-26 03:59:28 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-04-03 02:20:31 +0200 |
commit | e1e9f1e9eeeb899fb1dad10072fdf22ce5c9827e (patch) | |
tree | 10ada71dd3a165ccaf68d5d18dd1e7a9f7715b45 /lib/internal/util | |
parent | 7aa7971eec258ce1f8895ff66c5de78c6a59710f (diff) | |
download | android-node-v8-e1e9f1e9eeeb899fb1dad10072fdf22ce5c9827e.tar.gz android-node-v8-e1e9f1e9eeeb899fb1dad10072fdf22ce5c9827e.tar.bz2 android-node-v8-e1e9f1e9eeeb899fb1dad10072fdf22ce5c9827e.zip |
util: `inspect()` should not exceed `breakLength`
Using `util.inspect()` with the `compact` option set to a number
could result in output that exceeded the `breakLength` option. This
change makes sure that limit is taken into account.
PR-URL: https://github.com/nodejs/node/pull/26914
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/internal/util')
-rw-r--r-- | lib/internal/util/inspect.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 281ef2c87c..b2ac7200c4 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -913,6 +913,8 @@ function groupArrayElements(ctx, output) { approxCharHeights * (actualMax - bias) * output.length ) / (actualMax - bias) ), + // Do not exceed the breakLength. + Math.floor((ctx.breakLength - ctx.indentationLvl) / actualMax), // Limit array grouping for small `compact` modes as the user requested // minimal grouping. ctx.compact * 3, |