MCPcopy Create free account
hub / github.com/SimHacker/micropolis / quote

Function quote

turbogears/micropolis/htdocs/static/javascript/json2.js:206–223  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

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

Callers 1

strFunction · 0.70

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected