| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a653f23 commit e0e0ef7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,9 +77,7 @@ var Debug; | |||
| 77 | 77 | ||
| 78 | 78 | /* eslint-disable */ | |
| 79 | 79 | const strEscapeSequencesRegExp = /[\x00-\x1f\x27\x5c]/; | |
| 80 | - const keyEscapeSequencesRegExp = /[\x00-\x1f\x27]/; | ||
| 81 | 80 | const strEscapeSequencesReplacer = /[\x00-\x1f\x27\x5c]/g; | |
| 82 | - const keyEscapeSequencesReplacer = /[\x00-\x1f\x27]/g; | ||
| 83 | 81 | /* eslint-enable */ | |
| 84 | 82 | const keyStrRegExp = /^[a-zA-Z_][a-zA-Z_0-9]*$/; | |
| 85 | 83 | const colorRegExp = /\u001b\[\d\d?m/g; | |
@@ -133,34 +131,6 @@ function strEscape(str) { | |||
| 133 | 131 | return `'${result}'`; | |
| 134 | 132 | } | |
| 135 | 133 | ||
| 136 | - // Escape control characters and single quotes. | ||
| 137 | - // Note: for performance reasons this is not combined with strEscape | ||
| 138 | - function keyEscape(str) { | ||
| 139 | - if (str.length < 5000 && !keyEscapeSequencesRegExp.test(str)) | ||
| 140 | - return `'${str}'`; | ||
| 141 | - if (str.length > 100) | ||
| 142 | - return `'${str.replace(keyEscapeSequencesReplacer, escapeFn)}'`; | ||
| 143 | - var result = ''; | ||
| 144 | - var last = 0; | ||
| 145 | - for (var i = 0; i < str.length; i++) { | ||
| 146 | - const point = str.charCodeAt(i); | ||
| 147 | - if (point === 39 || point < 32) { | ||
| 148 | - if (last === i) { | ||
| 149 | - result += meta[point]; | ||
| 150 | - } else { | ||
| 151 | - result += `${str.slice(last, i)}${meta[point]}`; | ||
| 152 | - } | ||
| 153 | - last = i + 1; | ||
| 154 | - } | ||
| 155 | - } | ||
| 156 | - if (last === 0) { | ||
| 157 | - result = str; | ||
| 158 | - } else if (last !== i) { | ||
| 159 | - result += str.slice(last); | ||
| 160 | - } | ||
| 161 | - return `'${result}'`; | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | 134 | function tryStringify(arg) { | |
| 165 | 135 | try { | |
| 166 | 136 | return JSON.stringify(arg); | |
@@ -851,7 +821,7 @@ function formatProperty(ctx, value, recurseTimes, key, array) { | |||
| 851 | 821 | } else if (keyStrRegExp.test(key)) { | |
| 852 | 822 | name = ctx.stylize(key, 'name'); | |
| 853 | 823 | } else { | |
| 854 | - name = ctx.stylize(keyEscape(key), 'string'); | ||
| 824 | + name = ctx.stylize(strEscape(key), 'string'); | ||
| 855 | 825 | } | |
| 856 | 826 | ||
| 857 | 827 | return `${name}: ${str}`; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -558,25 +558,31 @@ assert.doesNotThrow(() => { | |||
| 558 | 558 | assert.strictEqual(util.inspect(x).includes('inspect'), true); | |
| 559 | 559 | } | |
| 560 | 560 | ||
| 561 | - // util.inspect should not display the escaped value of a key. | ||
| 561 | + // util.inspect should display the escaped value of a key. | ||
| 562 | 562 | { | |
| 563 | 563 | const w = { | |
| 564 | 564 | '\\': 1, | |
| 565 | 565 | '\\\\': 2, | |
| 566 | 566 | '\\\\\\': 3, | |
| 567 | 567 | '\\\\\\\\': 4, | |
| 568 | + '\n': 5, | ||
| 569 | + '\r': 6 | ||
| 568 | 570 | }; | |
| 569 | 571 | ||
| 570 | 572 | const y = ['a', 'b', 'c']; | |
| 571 | - y['\\\\\\'] = 'd'; | ||
| 573 | + y['\\\\'] = 'd'; | ||
| 574 | + y['\n'] = 'e'; | ||
| 575 | + y['\r'] = 'f'; | ||
| 572 | 576 | ||
| 573 | 577 | assert.strictEqual( | |
| 574 | 578 | util.inspect(w), | |
| 575 | - '{ \'\\\': 1, \'\\\\\': 2, \'\\\\\\\': 3, \'\\\\\\\\\': 4 }' | ||
| 579 | + '{ \'\\\\\': 1, \'\\\\\\\\\': 2, \'\\\\\\\\\\\\\': 3, ' + | ||
| 580 | + '\'\\\\\\\\\\\\\\\\\': 4, \'\\n\': 5, \'\\r\': 6 }' | ||
| 576 | 581 | ); | |
| 577 | 582 | assert.strictEqual( | |
| 578 | 583 | util.inspect(y), | |
| 579 | - '[ \'a\', \'b\', \'c\', \'\\\\\\\': \'d\' ]' | ||
| 584 | + '[ \'a\', \'b\', \'c\', \'\\\\\\\\\': \'d\', ' + | ||
| 585 | + '\'\\n\': \'e\', \'\\r\': \'f\' ]' | ||
| 580 | 586 | ); | |
| 581 | 587 | } | |
| 582 | 588 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments