From 08bd23970dbce4ccf8103abf27e4cfa1b747705b Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Mon, 5 Jun 2023 12:25:47 +0200 Subject: feat: add more options to Deno.inspect (#19337) For https://github.com/denoland/deno_std/issues/3404 --------- Co-authored-by: Yoshiya Hinosawa --- ext/console/01_console.js | 5 ++++- ext/node/polyfills/internal/util/inspect.mjs | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/console/01_console.js b/ext/console/01_console.js index dbbc549ca..11b6c549c 100644 --- a/ext/console/01_console.js +++ b/ext/console/01_console.js @@ -2427,6 +2427,7 @@ const denoInspectDefaultOptions = { colors: false, showProxy: false, breakLength: 80, + escapeSequences: true, compact: 3, sorted: false, getters: false, @@ -2500,7 +2501,9 @@ function quoteString(string, ctx) { ctx.quotes[0]; const escapePattern = new SafeRegExp(`(?=[${quote}\\\\])`, "g"); string = StringPrototypeReplace(string, escapePattern, "\\"); - string = replaceEscapeSequences(string); + if (ctx.escapeSequences) { + string = replaceEscapeSequences(string); + } return `${quote}${string}${quote}`; } diff --git a/ext/node/polyfills/internal/util/inspect.mjs b/ext/node/polyfills/internal/util/inspect.mjs index 671ab2acf..2d34db9c7 100644 --- a/ext/node/polyfills/internal/util/inspect.mjs +++ b/ext/node/polyfills/internal/util/inspect.mjs @@ -134,6 +134,7 @@ const inspectDefaultOptions = { colors: false, showProxy: false, breakLength: 80, + escapeSequences: true, compact: 3, sorted: false, getters: false, -- cgit v1.2.3