MCPcopy Create free account
hub / github.com/Faleij/json-stream-stringify / escapeString

Function escapeString

src/JsonStreamStringify.ts:45–58  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

43}
44
45function escapeString(string) {
46 // Modified code, original code by Douglas Crockford
47 // Original: https://github.com/douglascrockford/JSON-js/blob/master/json2.js
48
49 // If the string contains no control characters, no quote characters, and no
50 // backslash characters, then we can safely slap some quotes around it.
51 // Otherwise we must also replace the offending characters with safe escape
52 // sequences.
53
54 return string.replace(rxEscapable, (a) => {
55 const c = meta[a];
56 return typeof c === 'string' ? c : `\\u${a.charCodeAt(0).toString(16).padStart(4, '0')}`;
57 });
58}
59
60let primitiveToJSON: (value: any) => string;
61

Callers 3

setItemMethod · 0.85
readMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…