(value)
| 7257 | // `Quote(value)` operation defined in ES 5.1 section 15.12.3. |
| 7258 | var unicodePrefix = "\\u00"; |
| 7259 | var quote = function(value) { |
| 7260 | var result = '"', |
| 7261 | index = 0, |
| 7262 | length = value.length, |
| 7263 | useCharIndex = !charIndexBuggy || length > 10; |
| 7264 | var symbols = useCharIndex && (charIndexBuggy |
| 7265 | ? value.split("") |
| 7266 | : value); |
| 7267 | for (; index < length; index++) { |
| 7268 | var charCode = value.charCodeAt(index); |
| 7269 | // If the character is a control character, append its Unicode or |
| 7270 | // shorthand escape sequence; otherwise, append the character as-is. |
| 7271 | switch (charCode) { |
| 7272 | case 8: |
| 7273 | case 9: |
| 7274 | case 10: |
| 7275 | case 12: |
| 7276 | case 13: |
| 7277 | case 34: |
| 7278 | case 92: |
| 7279 | result += Escapes[charCode]; |
| 7280 | break; |
| 7281 | default: |
| 7282 | if (charCode < 32) { |
| 7283 | result += unicodePrefix + toPaddedString(2, charCode.toString(16)); |
| 7284 | break; |
| 7285 | } |
| 7286 | result += useCharIndex |
| 7287 | ? symbols[index] |
| 7288 | : value.charAt(index); |
| 7289 | } |
| 7290 | } |
| 7291 | return result + '"'; |
| 7292 | }; |
| 7293 | |
| 7294 | // Internal: Recursively serializes an object. Implements the |
| 7295 | // `Str(key, holder)`, `JO(value)`, and `JA(value)` operations. |
no test coverage detected