(key: string)
| 28 | const NUMBER_REGEXP = /^(?:0|[1-9]\d*)$/; |
| 29 | |
| 30 | export 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 | |
| 40 | export function stringifyIdentifierIfNeeded(key: string) { |
| 41 | if (VALID_IDENTIFIER_REGEXP.test(key)) { |
no test coverage detected
searching dependent graphs…