Hyperlinkv0.8.0-beta.28

Chunk

Chunk.dropWhileconsteffect/Chunk.ts:876
<A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Chunk<A>
<A>(self: Chunk<A>, predicate: Predicate<A>): Chunk<A>

Drops all elements so long as the predicate returns true.

Example (Dropping elements while a predicate matches)

import { Chunk } from "effect"

const chunk = Chunk.make(1, 2, 3, 4, 5)
const result = Chunk.dropWhile(chunk, (n) => n < 3)
console.log(Chunk.toArray(result)) // [3, 4, 5]
elements
Source effect/Chunk.ts:87612 lines
export const dropWhile: {
  <A>(predicate: Predicate<NoInfer<A>>): (self: Chunk<A>) => Chunk<A>
  <A>(self: Chunk<A>, predicate: Predicate<A>): Chunk<A>
} = dual(2, <A>(self: Chunk<A>, predicate: Predicate<A>): Chunk<A> => {
  const arr = toReadonlyArray(self)
  const len = arr.length
  let i = 0
  while (i < len && predicate(arr[i]!)) {
    i++
  }
  return drop(self, i)
})
Referenced by 1 symbols