| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 20d978d commit 54288bd
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2394,6 +2394,9 @@ added: | |||
| 2394 | 2394 | - v21.7.0 | |
| 2395 | 2395 | - v20.12.0 | |
| 2396 | 2396 | changes: | |
| 2397 | + - version: REPLACEME | ||
| 2398 | + pr-url: https://github.com/nodejs/node/pull/58437 | ||
| 2399 | + description: Added the `'none'` format as a non-op format. | ||
| 2397 | 2400 | - version: v22.13.0 | |
| 2398 | 2401 | pr-url: https://github.com/nodejs/node/pull/56265 | |
| 2399 | 2402 | description: styleText is now stable. | |
@@ -2467,6 +2470,8 @@ console.log( | |||
| 2467 | 2470 | ); | |
| 2468 | 2471 | ``` | |
| 2469 | 2472 | ||
| 2473 | + The special format value `none` applies no additional styling to the text. | ||
| 2474 | + | ||
| 2470 | 2475 | The full list of formats can be found in [modifiers][]. | |
| 2471 | 2476 | ||
| 2472 | 2477 | ## Class: `util.TextDecoder` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -217,10 +217,11 @@ function pad(n) { | |||
| 217 | 217 | } | |
| 218 | 218 | ||
| 219 | 219 | /** | |
| 220 | - * @param {string} code | ||
| 220 | + * @param {string} [code] | ||
| 221 | 221 | * @returns {string} | |
| 222 | 222 | */ | |
| 223 | 223 | function escapeStyleCode(code) { | |
| 224 | + if (code === undefined) return ''; | ||
| 224 | 225 | return `\u001b[${code}m`; | |
| 225 | 226 | } | |
| 226 | 227 | ||
@@ -256,6 +257,7 @@ function styleText(format, text, { validateStream = true, stream = process.stdou | |||
| 256 | 257 | let left = ''; | |
| 257 | 258 | let right = ''; | |
| 258 | 259 | for (const key of formatArray) { | |
| 260 | + if (key === 'none') continue; | ||
| 259 | 261 | const formatCodes = inspect.colors[key]; | |
| 260 | 262 | // If the format is not a valid style, throw an error | |
| 261 | 263 | if (formatCodes == null) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -75,6 +75,8 @@ assert.strictEqual( | |||
| 75 | 75 | styled, | |
| 76 | 76 | ); | |
| 77 | 77 | ||
| 78 | + assert.strictEqual(util.styleText('none', 'test'), 'test'); | ||
| 79 | + | ||
| 78 | 80 | const fd = common.getTTYfd(); | |
| 79 | 81 | if (fd !== -1) { | |
| 80 | 82 | const writeStream = new WriteStream(fd); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments