MCPcopy Create free account
hub / github.com/HtmlUnit/htmlunit / quote

Function quote

src/test/resources/json2.js:204–219  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

202
203
204 function quote(string) {
205
206// If the string contains no control characters, no quote characters, and no
207// backslash characters, then we can safely slap some quotes around it.
208// Otherwise we must also replace the offending characters with safe escape
209// sequences.
210
211 escapable.lastIndex = 0;
212 return escapable.test(string) ?
213 '"' + string.replace(escapable, function (a) {
214 var c = meta[a];
215 return typeof c === 'string' ? c :
216 '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
217 }) + '"' :
218 '"' + string + '"';
219 }
220
221
222 function str(key, holder) {

Callers 1

strFunction · 0.70

Calls 4

testMethod · 0.45
replaceMethod · 0.45
sliceMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…