fix(core): clean up Effect audit patterns (#35174)
This commit is contained in:
parent
08293e74a0
commit
1b88ff8d53
18 changed files with 118 additions and 62 deletions
|
|
@ -35,6 +35,7 @@ const RawMatch = Schema.Struct({
|
|||
),
|
||||
}),
|
||||
})
|
||||
const decodeJsonRecord = Schema.decodeUnknownEffect(Schema.UnknownFromJsonString)
|
||||
|
||||
type RawMatchData = (typeof RawMatch.Type)["data"]
|
||||
|
||||
|
|
@ -232,10 +233,7 @@ const layer = Layer.effect(
|
|||
parse: (line) =>
|
||||
(Buffer.byteLength(line, "utf8") > MAX_RECORD_BYTES
|
||||
? Effect.fail(failure(`Ripgrep JSON record exceeded ${MAX_RECORD_BYTES} bytes`))
|
||||
: Effect.try({
|
||||
try: () => JSON.parse(line) as unknown,
|
||||
catch: (cause) => failure("Invalid ripgrep JSON output", cause),
|
||||
})
|
||||
: decodeJsonRecord(line).pipe(Effect.mapError((cause) => failure("Invalid ripgrep JSON output", cause)))
|
||||
).pipe(
|
||||
Effect.flatMap((json) => {
|
||||
if (!json || typeof json !== "object" || !("type" in json) || json.type !== "match")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue