(text)
| 199 | } |
| 200 | |
| 201 | function parseWithBigInt(text) { |
| 202 | const fixed = normalizeLooseJSONSource(text); |
| 203 | const ordered = markIntegerIndexKeys(fixed); |
| 204 | |
| 205 | const marked = ordered.replace( |
| 206 | /([:,\[]\s*)(-?\d{16,})(\s*)(?=(?:,|\]|\}|$))/g, |
| 207 | function (match, prefix, number, spaces, offset) { |
| 208 | if (isInsideQuotedSegment(ordered, offset)) return match; |
| 209 | return prefix + '"__BigInt__' + number + '"' + spaces; |
| 210 | }, |
| 211 | ); |
| 212 | |
| 213 | return JSON.parse(marked, function (_key, value) { |
| 214 | if (typeof value === 'string' && value.startsWith('__BigInt__')) { |
| 215 | try { |
| 216 | return BigInt(value.slice(10)); |
| 217 | } catch (_) { |
| 218 | return value.slice(10); |
| 219 | } |
| 220 | } |
| 221 | return value; |
| 222 | }); |
| 223 | } |
| 224 | |
| 225 | function isJSONContainer(value) { |
| 226 | if (typeof value !== 'object' || value === null) return false; |
no test coverage detected