Hyperlinkv0.8.0-beta.28

Chunk

Chunk.containsWithconsteffect/Chunk.ts:2592
<A>(isEquivalent: (self: A, that: A) => boolean): {
  (a: A): (self: Chunk<A>) => boolean
  (self: Chunk<A>, a: A): boolean
}

Returns a function that checks if a Chunk contains a given value using a provided isEquivalent function.

Example (Checking membership with custom equivalence)

import { Chunk } from "effect"

const chunk = Chunk.make({ id: 1, name: "Alice" }, { id: 2, name: "Bob" })

// Custom equivalence by id
const containsById = Chunk.containsWith<{ id: number; name: string }>((a, b) =>
  a.id === b.id
)
console.log(containsById(chunk, { id: 1, name: "Different" })) // true
console.log(containsById(chunk, { id: 3, name: "Charlie" })) // false

// Case-insensitive string comparison
const words = Chunk.make("Apple", "Banana", "Cherry")
const containsCaseInsensitive = Chunk.containsWith<string>((a, b) =>
  a.toLowerCase() === b.toLowerCase()
)
console.log(containsCaseInsensitive(words, "apple")) // true
console.log(containsCaseInsensitive(words, "grape")) // false
elements
Source effect/Chunk.ts:25926 lines
export const containsWith: <A>(
  isEquivalent: (self: A, that: A) => boolean
) => {
  (a: A): (self: Chunk<A>) => boolean
  (self: Chunk<A>, a: A): boolean
} = RA.containsWith