(string)
| 117 | } |
| 118 | |
| 119 | function escape(string) { |
| 120 | let output = ""; |
| 121 | let counter = 0; |
| 122 | |
| 123 | while (counter < string.length) { |
| 124 | // eslint-disable-next-line no-plusplus |
| 125 | const character = string.charAt(counter++); |
| 126 | |
| 127 | let value; |
| 128 | |
| 129 | // eslint-disable-next-line no-control-regex |
| 130 | if (/[\t\n\f\r\x0B]/.test(character)) { |
| 131 | const codePoint = character.charCodeAt(); |
| 132 | |
| 133 | value = `\\${codePoint.toString(16).toUpperCase()} `; |
| 134 | } else if (character === "\\" || regexSingleEscape.test(character)) { |
| 135 | value = `\\${character}`; |
| 136 | } else { |
| 137 | value = character; |
| 138 | } |
| 139 | |
| 140 | output += value; |
| 141 | } |
| 142 | |
| 143 | const firstChar = string.charAt(0); |
| 144 | |
| 145 | if (/^-[-\d]/.test(output)) { |
| 146 | output = `\\-${output.slice(1)}`; |
| 147 | } else if (/\d/.test(firstChar)) { |
| 148 | output = `\\3${firstChar} ${output.slice(1)}`; |
| 149 | } |
| 150 | |
| 151 | // Remove spaces after `\HEX` escapes that are not followed by a hex digit, |
| 152 | // since they’re redundant. Note that this is only possible if the escape |
| 153 | // sequence isn’t preceded by an odd number of backslashes. |
| 154 | output = output.replace(regexExcessiveSpaces, ($0, $1, $2) => { |
| 155 | if ($1 && $1.length % 2) { |
| 156 | // It’s not safe to remove the space, so don’t. |
| 157 | return $0; |
| 158 | } |
| 159 | |
| 160 | // Strip the space. |
| 161 | return ($1 || "") + $2; |
| 162 | }); |
| 163 | |
| 164 | return output; |
| 165 | } |
| 166 | |
| 167 | function gobbleHex(str) { |
| 168 | const lower = str.toLowerCase(); |
no outgoing calls
no test coverage detected
searching dependent graphs…