diff options
author | Weijia Wang <starkwang@126.com> | 2019-03-18 19:31:07 +0800 |
---|---|---|
committer | Weijia Wang <381152119@qq.com> | 2019-03-21 21:38:02 +0800 |
commit | c8d3a73c8b673792e315759b70cf4822b64b3e45 (patch) | |
tree | 39f35c7327e82964acf66f63c3e9d1c919c3382b /lib/internal/util | |
parent | 1935625df4f56bd77c57ec100a9222c77e9d440c (diff) | |
download | android-node-v8-c8d3a73c8b673792e315759b70cf4822b64b3e45.tar.gz android-node-v8-c8d3a73c8b673792e315759b70cf4822b64b3e45.tar.bz2 android-node-v8-c8d3a73c8b673792e315759b70cf4822b64b3e45.zip |
lib: use Array#includes instead of Array#indexOf
PR-URL: https://github.com/nodejs/node/pull/26732
Refs: https://github.com/nodejs/node/issues/26568
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'lib/internal/util')
-rw-r--r-- | lib/internal/util/inspect.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 4cee2d8b9f..dc97e6dceb 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -288,12 +288,12 @@ function strEscape(str) { // instead wrap the text in double quotes. If double quotes exist, check for // backticks. If they do not exist, use those as fallback instead of the // double quotes. - if (str.indexOf("'") !== -1) { + if (str.includes("'")) { // This invalidates the charCode and therefore can not be matched for // anymore. - if (str.indexOf('"') === -1) { + if (!str.includes('"')) { singleQuote = -1; - } else if (str.indexOf('`') === -1 && str.indexOf('${') === -1) { + } else if (!str.includes('`') && !str.includes('${')) { singleQuote = -2; } if (singleQuote !== 39) { @@ -557,7 +557,7 @@ function formatValue(ctx, value, recurseTimes, typedArray) { // Using an array here is actually better for the average case than using // a Set. `seen` will only check for the depth and will never grow too large. - if (ctx.seen.indexOf(value) !== -1) + if (ctx.seen.includes(value)) return ctx.stylize('[Circular]', 'special'); return formatRaw(ctx, value, recurseTimes, typedArray); |