Hyperlinkv0.8.0-beta.28

Chunk

Chunk.findLastIndexconsteffect/Chunk.ts:2724
<A>(predicate: Predicate<A>): (self: Chunk<A>) => O.Option<number>
<A>(self: Chunk<A>, predicate: Predicate<A>): O.Option<number>

Returns the last index for which a predicate holds.

Example (Finding the last matching index)

import { Chunk } from "effect"

const chunk = Chunk.make(1, 2, 3, 4, 5)
const result = Chunk.findLastIndex(chunk, (n) => n < 4)
console.log(result) // Option.some(2)

// No match found
const notFound = Chunk.findLastIndex(chunk, (n) => n > 10)
console.log(notFound) // Option.none()

// Find last even number index
const lastEven = Chunk.findLastIndex(chunk, (n) => n % 2 === 0)
console.log(lastEven) // Option.some(3)
elements
Source effect/Chunk.ts:27247 lines
export const findLastIndex: {
  <A>(predicate: Predicate<A>): (self: Chunk<A>) => O.Option<number>
  <A>(self: Chunk<A>, predicate: Predicate<A>): O.Option<number>
} = dual(
  2,
  <A>(self: Chunk<A>, predicate: Predicate<A>): O.Option<number> => RA.findLastIndex(self, predicate)
)