MCPcopy
hub / github.com/rollup/rollup / stringifyObjectKeyIfNeeded

Function stringifyObjectKeyIfNeeded

src/utils/identifierHelpers.ts:30–38  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

28const NUMBER_REGEXP = /^(?:0|[1-9]\d*)$/;
29
30export function stringifyObjectKeyIfNeeded(key: string) {
31 if (VALID_IDENTIFIER_REGEXP.test(key)) {
32 return key === '__proto__' ? '["__proto__"]' : key;
33 }
34 if (NUMBER_REGEXP.test(key) && +key <= Number.MAX_SAFE_INTEGER) {
35 return key;
36 }
37 return JSON.stringify(key);
38}
39
40export function stringifyIdentifierIfNeeded(key: string) {
41 if (VALID_IDENTIFIER_REGEXP.test(key)) {

Callers 4

getObjectFunction · 0.90
getExportsBlockFunction · 0.90
renderBlockMethod · 0.90
renderMethod · 0.90

Calls 1

testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…