| 204 | |
| 205 | |
| 206 | function quote(string) { |
| 207 | |
| 208 | // If the string contains no control characters, no quote characters, and no |
| 209 | // backslash characters, then we can safely slap some quotes around it. |
| 210 | // Otherwise we must also replace the offending characters with safe escape |
| 211 | // sequences. |
| 212 | |
| 213 | escapable.lastIndex = 0; |
| 214 | return escapable.test(string) ? |
| 215 | '"' + string.replace(escapable, function (a) { |
| 216 | var c = meta[a]; |
| 217 | if (typeof c === 'string') { |
| 218 | return c; |
| 219 | } |
| 220 | return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); |
| 221 | }) + '"' : |
| 222 | '"' + string + '"'; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | function str(key, holder) { |