(s)
| 95 | // Turns a string into a legal JavaScript string |
| 96 | // Copied from peg.js, thanks to David Majda |
| 97 | function stringify(s) { |
| 98 | /* |
| 99 | * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a string |
| 100 | * literal except for the closing quote character, backslash, carriage return, |
| 101 | * line separator, paragraph separator, and line feed. Any character may |
| 102 | * appear in the form of an escape sequence. |
| 103 | * |
| 104 | * For portability, we also escape all non-ASCII characters. |
| 105 | */ |
| 106 | return (s || "") |
| 107 | .replace(/\\/g, '\\\\') // backslash |
| 108 | .replace(/"/g, '\\"') // double quote character |
| 109 | .replace(/'/g, "\\'") // single quote character |
| 110 | .replace(/\r/g, '\\r') // carriage return |
| 111 | .replace(/\n/g, '\\n') // line feed |
| 112 | .replace(/[\x00-\x1f\x80-\uFFFF]/g, escape); // non-ASCII characters |
| 113 | }; |
| 114 | |
| 115 | // Helper function to save a file |
| 116 | function saveFile(filepath,content) { |
no outgoing calls
no test coverage detected