(str)
| 170 | // Escape control characters, single quotes and the backslash. |
| 171 | // This is similar to JSON stringify escaping. |
| 172 | function strEscape(str) |
| 173 | { |
| 174 | // Some magic numbers that worked out fine while benchmarking with v8 6.0 |
| 175 | if (str.length < 5000 && !strEscapeSequencesRegExp.test(str)) |
| 176 | return `'${str}'`; |
| 177 | if (str.length > 100) |
| 178 | return `'${str.replace(strEscapeSequencesReplacer, escapeFn)}'`; |
| 179 | let result = ''; |
| 180 | let last = 0; |
| 181 | let i; |
| 182 | for (i = 0; i < str.length; i++) |
| 183 | { |
| 184 | const point = str.charCodeAt(i); |
| 185 | if (point === 39 || point === 92 || point < 32) |
| 186 | { |
| 187 | if (last === i) |
| 188 | { |
| 189 | result += meta[point]; |
| 190 | } |
| 191 | else |
| 192 | { |
| 193 | result += `${str.slice(last, i)}${meta[point]}`; |
| 194 | } |
| 195 | last = i + 1; |
| 196 | } |
| 197 | } |
| 198 | if (last === 0) |
| 199 | { |
| 200 | result = str; |
| 201 | } |
| 202 | else if (last !== i) |
| 203 | { |
| 204 | result += str.slice(last); |
| 205 | } |
| 206 | return `'${result}'`; |
| 207 | } |
| 208 | |
| 209 | function tryStringify(arg) |
| 210 | { |
no outgoing calls
no test coverage detected