Hyperlinkv0.8.0-beta.28

Chunk

Chunk.takeRightconsteffect/Chunk.ts:2156
(n: number): <A>(self: Chunk<A>) => Chunk<A>
<A>(self: Chunk<A>, n: number): Chunk<A>

Takes the last n elements.

Example (Taking elements from the end)

import { Chunk } from "effect"

const chunk = Chunk.make(1, 2, 3, 4, 5, 6)
const lastThree = Chunk.takeRight(chunk, 3)
console.log(Chunk.toArray(lastThree)) // [4, 5, 6]

// Take more than available
const all = Chunk.takeRight(chunk, 10)
console.log(Chunk.toArray(all)) // [1, 2, 3, 4, 5, 6]

// Take zero
const none = Chunk.takeRight(chunk, 0)
console.log(Chunk.toArray(none)) // []
elements
Source effect/Chunk.ts:21564 lines
export const takeRight: {
  (n: number): <A>(self: Chunk<A>) => Chunk<A>
  <A>(self: Chunk<A>, n: number): Chunk<A>
} = dual(2, <A>(self: Chunk<A>, n: number): Chunk<A> => drop(self, self.length - n))