Hyperlinkv0.8.0-beta.28

Tuple

Tuple.omitconsteffect/Tuple.ts:166
<
  const T extends ReadonlyArray<unknown>,
  const I extends ReadonlyArray<Indices<T>>
>(
  indices: I
): (self: T) => OmitTuple<T, I[number]>
<
  const T extends ReadonlyArray<unknown>,
  const I extends ReadonlyArray<Indices<T>>
>(
  self: T,
  indices: I
): OmitTuple<T, I[number]>

Creates a new tuple with the elements at the specified indices removed.

When to use

Use to drop elements from a tuple by position.

Details

Elements not at the specified indices are kept in their original order.

Example (Removing elements by index)

import { Tuple } from "effect"

const result = Tuple.omit(["a", "b", "c", "d"], [1, 3])
console.log(result) // ["a", "c"]
filteringpick
Source effect/Tuple.ts:16618 lines
export const omit: {
  <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(
    indices: I
  ): (self: T) => OmitTuple<T, I[number]>
  <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(
    self: T,
    indices: I
  ): OmitTuple<T, I[number]>
} = dual(
  2,
  <const T extends ReadonlyArray<unknown>>(
    self: T,
    indices: ReadonlyArray<number>
  ) => {
    const toDrop = new Set<number>(indices)
    return self.filter((_, i) => !toDrop.has(i))
  }
)