Hyperlinkv0.8.0-beta.28

Chunk

Chunk.someconsteffect/Chunk.ts:2794
<A>(predicate: Predicate<NoInfer<A>>): (
  self: Chunk<A>
) => self is NonEmptyChunk<A>
<A>(self: Chunk<A>, predicate: Predicate<A>): self is NonEmptyChunk<A>

Checks whether a predicate holds true for some Chunk element.

Example (Checking for some matching element)

import { Chunk } from "effect"

const chunk = Chunk.make(1, 2, 3, 4, 5)
console.log(Chunk.some(chunk, (n) => n > 4)) // true
console.log(Chunk.some(chunk, (n) => n > 10)) // false

// Empty chunk returns false
const empty = Chunk.empty<number>()
console.log(Chunk.some(empty, (n) => n > 0)) // false

// Check for specific value
const words = Chunk.make("apple", "banana", "cherry")
console.log(Chunk.some(words, (word) => word.includes("ban"))) // true
elements
Source effect/Chunk.ts:27947 lines
export const some: {
  <A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => self is NonEmptyChunk<A>
  <A>(self: Chunk<A>, predicate: Predicate<A>): self is NonEmptyChunk<A>
} = dual(
  2,
  <A>(self: Chunk<A>, predicate: Predicate<A>): self is NonEmptyChunk<A> => RA.fromIterable(self).some(predicate)
)