MCPcopy Create free account
hub / github.com/uiwjs/react-codemirror / formatKey

Function formatKey

extensions/langs/gen-langs-map.cjs:269–278  ·  view source on GitHub ↗
(key)

Source from the content-addressed store, hash-verified

267
268// 格式化 key 的函数
269function formatKey(key) {
270 // 检查是否为有效的 JavaScript 标识符
271 const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
272
273 if (isValidIdentifier) {
274 return key; // 不用引号
275 } else {
276 return `'${key.replace(/'/g, "\\'")}'`; // 用单引号,转义内部的单引号
277 }
278}
279
280// 输出文件内容
281let out = '';

Callers 1

gen-langs-map.cjsFile · 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…