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

Function _parse

packages/effect/src/unstable/ai/Tool.ts:1921–1939  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

1919const suspectConstructorRx = /"constructor"\s*:/
1920
1921function _parse(text: string) {
1922 // Parse normally
1923 const obj = JSON.parse(text)
1924
1925 // Ignore null and non-objects
1926 if (obj === null || typeof obj !== "object") {
1927 return obj
1928 }
1929
1930 if (
1931 suspectProtoRx.test(text) === false &&
1932 suspectConstructorRx.test(text) === false
1933 ) {
1934 return obj
1935 }
1936
1937 // Scan result for proto keys
1938 return filter(obj)
1939}
1940
1941function filter(obj: any) {
1942 let next = [obj]

Callers 1

unsafeSecureJsonParseFunction · 0.85

Calls 2

filterFunction · 0.70
parseMethod · 0.45

Tested by

no test coverage detected