MCPcopy Create free account
hub / github.com/Effect-TS/effect / _parse

Function _parse

packages/ai/ai/src/Tool.ts:1460–1478  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

1458const suspectConstructorRx = /"constructor"\s*:/
1459
1460function _parse(text: string) {
1461 // Parse normally
1462 const obj = JSON.parse(text)
1463
1464 // Ignore null and non-objects
1465 if (obj === null || typeof obj !== "object") {
1466 return obj
1467 }
1468
1469 if (
1470 suspectProtoRx.test(text) === false &&
1471 suspectConstructorRx.test(text) === false
1472 ) {
1473 return obj
1474 }
1475
1476 // Scan result for proto keys
1477 return filter(obj)
1478}
1479
1480function filter(obj: any) {
1481 let next = [obj]

Callers 1

unsafeSecureJsonParseFunction · 0.85

Calls 2

parseMethod · 0.80
filterFunction · 0.70

Tested by

no test coverage detected