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

Function Struct

packages/effect/src/Predicate.ts:1508–1525  ·  view source on GitHub ↗
(
  fields: R
)

Source from the content-addressed store, hash-verified

1506 * @since 4.0.0
1507 */
1508export function Struct<R extends Record<string, Predicate.Any>>(
1509 fields: R
1510): [Extract<R[keyof R], Refinement.Any>] extends [never] ? Predicate<{ readonly [K in keyof R]: Predicate.In<R[K]> }> :
1511 Refinement<
1512 { readonly [K in keyof R]: R[K] extends Refinement.Any ? Refinement.In<R[K]> : Predicate.In<R[K]> },
1513 { readonly [K in keyof R]: R[K] extends Refinement.Any ? Refinement.Out<R[K]> : Predicate.In<R[K]> }
1514 >
1515{
1516 const keys = Object.keys(fields)
1517 return ((a: Record<string, unknown>) => {
1518 for (const key of keys) {
1519 if (!fields[key](a[key] as never)) {
1520 return false
1521 }
1522 }
1523 return true
1524 }) as any
1525}
1526
1527/**
1528 * Negates a predicate.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected