@pleisto/active-support
    Preparing search index...

    Function when

    • P.when((value) => boolean) returns a pattern which matches if the predicate returns true for the current input.

      Read the documentation for P.when on GitHub

      Type Parameters

      • input
      • predicate extends (value: input) => unknown

      Parameters

      Returns GuardP<
          input,
          predicate extends (value: any) => value is narrowed ? narrowed : never,
      >

      match<{ age: number }>(value)
      .with({ age: P.when(age => age > 21) }, (x) => 'will match if value.age > 21'
      )
    • P.when((value) => boolean) returns a pattern which matches if the predicate returns true for the current input.

      Read the documentation for P.when on GitHub

      Type Parameters

      • input
      • narrowed
      • excluded

      Parameters

      Returns GuardExcludeP<input, narrowed, excluded>

      match<{ age: number }>(value)
      .with({ age: P.when(age => age > 21) }, (x) => 'will match if value.age > 21'
      )