MCPcopy Create free account
hub / github.com/codemix/htmling / stringEscape

Function stringEscape

lib/parser.js:951–966  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

949
950 function buildMessage(expected, found) {
951 function stringEscape(s) {
952 function hex(ch) { return ch.charCodeAt(0).toString(16).toUpperCase(); }
953
954 return s
955 .replace(/\\/g, '\\\\')
956 .replace(/"/g, '\\"')
957 .replace(/\x08/g, '\\b')
958 .replace(/\t/g, '\\t')
959 .replace(/\n/g, '\\n')
960 .replace(/\f/g, '\\f')
961 .replace(/\r/g, '\\r')
962 .replace(/[\x00-\x07\x0B\x0E\x0F]/g, function(ch) { return '\\x0' + hex(ch); })
963 .replace(/[\x10-\x1F\x80-\xFF]/g, function(ch) { return '\\x' + hex(ch); })
964 .replace(/[\u0180-\u0FFF]/g, function(ch) { return '\\u0' + hex(ch); })
965 .replace(/[\u1080-\uFFFF]/g, function(ch) { return '\\u' + hex(ch); });
966 }
967
968 var expectedDescs = new Array(expected.length),
969 expectedDesc, foundDesc, i;

Callers 1

buildMessageFunction · 0.85

Calls 1

hexFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…