UNPKG

352 BJavaScriptView Raw
1function _quote(s) {
2 var escaped = s.replace(/\\/g, '\\\\').replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace
3 .replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/\v/g, '\\v').replace(/\0/g, '\\0');
4 return '"' + escaped.replace(/"/g, '\\"') + '"';
5}
6
7module.exports = _quote;
\No newline at end of file