Hyperlinkv0.8.0-beta.28

Filter

Filter.hasconsteffect/Filter.ts:316
<K>(key: K): <Input extends { readonly has: (key: K) => boolean }>(
  input: Input
) => Result.Result<Input, Input>

Creates a Filter that passes inputs whose has(key) method returns true for the specified key.

When to use

Use to keep inputs that expose a has method, such as Set or Map, when they contain a required key.

Source effect/Filter.ts:3163 lines
export const has =
  <K>(key: K) => <Input extends { readonly has: (key: K) => boolean }>(input: Input): Result.Result<Input, Input> =>
    input.has(key) ? Result.succeed(input) : Result.fail(input)