| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 23c98fa commit a37eb32
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,9 +81,7 @@ var Debug; | |||
| 81 | 81 | ||
| 82 | 82 | /* eslint-disable */ | |
| 83 | 83 | const strEscapeSequencesRegExp = /[\x00-\x1f\x27\x5c]/; | |
| 84 | - const keyEscapeSequencesRegExp = /[\x00-\x1f\x27]/; | ||
| 85 | 84 | const strEscapeSequencesReplacer = /[\x00-\x1f\x27\x5c]/g; | |
| 86 | - const keyEscapeSequencesReplacer = /[\x00-\x1f\x27]/g; | ||
| 87 | 85 | /* eslint-enable */ | |
| 88 | 86 | const keyStrRegExp = /^[a-zA-Z_][a-zA-Z_0-9]*$/; | |
| 89 | 87 | const colorRegExp = /\u001b\[\d\d?m/g; | |
@@ -137,34 +135,6 @@ function strEscape(str) { | |||
| 137 | 135 | return `'${result}'`; | |
| 138 | 136 | } | |
| 139 | 137 | ||
| 140 | - // Escape control characters and single quotes. | ||
| 141 | - // Note: for performance reasons this is not combined with strEscape | ||
| 142 | - function keyEscape(str) { | ||
| 143 | - if (str.length < 5000 && !keyEscapeSequencesRegExp.test(str)) | ||
| 144 | - return `'${str}'`; | ||
| 145 | - if (str.length > 100) | ||
| 146 | - return `'${str.replace(keyEscapeSequencesReplacer, escapeFn)}'`; | ||
| 147 | - var result = ''; | ||
| 148 | - var last = 0; | ||
| 149 | - for (var i = 0; i < str.length; i++) { | ||
| 150 | - const point = str.charCodeAt(i); | ||
| 151 | - if (point === 39 || point < 32) { | ||
| 152 | - if (last === i) { | ||
| 153 | - result += meta[point]; | ||
| 154 | - } else { | ||
| 155 | - result += `${str.slice(last, i)}${meta[point]}`; | ||
| 156 | - } | ||
| 157 | - last = i + 1; | ||
| 158 | - } | ||
| 159 | - } | ||
| 160 | - if (last === 0) { | ||
| 161 | - result = str; | ||
| 162 | - } else if (last !== i) { | ||
| 163 | - result += str.slice(last); | ||
| 164 | - } | ||
| 165 | - return `'${result}'`; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | 138 | function tryStringify(arg) { | |
| 169 | 139 | try { | |
| 170 | 140 | return JSON.stringify(arg); | |
@@ -859,7 +829,7 @@ function formatProperty(ctx, value, recurseTimes, key, array) { | |||
| 859 | 829 | } else if (keyStrRegExp.test(key)) { | |
| 860 | 830 | name = ctx.stylize(key, 'name'); | |
| 861 | 831 | } else { | |
| 862 | - name = ctx.stylize(keyEscape(key), 'string'); | ||
| 832 | + name = ctx.stylize(strEscape(key), 'string'); | ||
| 863 | 833 | } | |
| 864 | 834 | ||
| 865 | 835 | return `${name}: ${str}`; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -567,25 +567,31 @@ assert.doesNotThrow(() => { | |||
| 567 | 567 | assert.strictEqual(util.inspect(x).includes('inspect'), true); | |
| 568 | 568 | } | |
| 569 | 569 | ||
| 570 | - // util.inspect should not display the escaped value of a key. | ||
| 570 | + // util.inspect should display the escaped value of a key. | ||
| 571 | 571 | { | |
| 572 | 572 | const w = { | |
| 573 | 573 | '\\': 1, | |
| 574 | 574 | '\\\\': 2, | |
| 575 | 575 | '\\\\\\': 3, | |
| 576 | 576 | '\\\\\\\\': 4, | |
| 577 | + '\n': 5, | ||
| 578 | + '\r': 6 | ||
| 577 | 579 | }; | |
| 578 | 580 | ||
| 579 | 581 | const y = ['a', 'b', 'c']; | |
| 580 | - y['\\\\\\'] = 'd'; | ||
| 582 | + y['\\\\'] = 'd'; | ||
| 583 | + y['\n'] = 'e'; | ||
| 584 | + y['\r'] = 'f'; | ||
| 581 | 585 | ||
| 582 | 586 | assert.strictEqual( | |
| 583 | 587 | util.inspect(w), | |
| 584 | - '{ \'\\\': 1, \'\\\\\': 2, \'\\\\\\\': 3, \'\\\\\\\\\': 4 }' | ||
| 588 | + '{ \'\\\\\': 1, \'\\\\\\\\\': 2, \'\\\\\\\\\\\\\': 3, ' + | ||
| 589 | + '\'\\\\\\\\\\\\\\\\\': 4, \'\\n\': 5, \'\\r\': 6 }' | ||
| 585 | 590 | ); | |
| 586 | 591 | assert.strictEqual( | |
| 587 | 592 | util.inspect(y), | |
| 588 | - '[ \'a\', \'b\', \'c\', \'\\\\\\\': \'d\' ]' | ||
| 593 | + '[ \'a\', \'b\', \'c\', \'\\\\\\\\\': \'d\', ' + | ||
| 594 | + '\'\\n\': \'e\', \'\\r\': \'f\' ]' | ||
| 589 | 595 | ); | |
| 590 | 596 | } | |
| 591 | 597 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments