MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / escapeJSONKey

Function escapeJSONKey

src/jsifier.mjs:75–79  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

73}
74
75function escapeJSONKey(x) {
76 if (/^[\d\w_]+$/.exec(x) || x[0] === '"' || x[0] === "'") return x;
77 assert(!x.includes("'"), 'cannot have internal single quotes in keys: ' + x);
78 return "'" + x + "'";
79}
80
81// JSON.stringify will completely omit function objects. This function is
82// similar but preserves functions.

Callers 1

stringifyWithFunctionsFunction · 0.85

Calls 1

assertFunction · 0.70

Tested by

no test coverage detected