Hyperlinkv0.9.0-beta.0

Array

Array.dropRightconsteffect/Array.ts:1541
(n: number): <A>(self: Iterable<A>) => Array<A>
<A>(self: Iterable<A>, n: number): Array<A>

Removes the last n elements, creating a new array.

When to use

Use to remove the last n elements from an iterable.

Details

n is clamped to [0, length].

Example (Dropping from the end)

import { Array } from "effect"

console.log(Array.dropRight([1, 2, 3, 4, 5], 2)) // [1, 2, 3]
Source effect/Array.ts:15417 lines
export const dropRight: {
  (n: number): <A>(self: Iterable<A>) => Array<A>
  <A>(self: Iterable<A>, n: number): Array<A>
} = dual(2, <A>(self: Iterable<A>, n: number): Array<A> => {
  const input = fromIterable(self)
  return input.slice(0, input.length - clamp(n, input))
})