<
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 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]>
}
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"]
omit: {
<const function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>T extends interface ReadonlyArray<T>ReadonlyArray<unknown>, const function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>I extends interface ReadonlyArray<T>ReadonlyArray<type Indices<
T extends ReadonlyArray<unknown>
> = Partial<T>["length"] extends T["length"]
? never
: Partial<T>["length"]
Indices<function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>T>>>(
indices: const I extends ReadonlyArray<Indices<T>>indices: function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>I
): (self: const T extends ReadonlyArray<unknown>self: function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>T) => type OmitTuple<
T extends ReadonlyArray<unknown>,
K
> = 0 extends T["length"]
? []
: _BuildTuple<
T,
Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
>,
0 extends Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
>
? [
T[Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
> &
0]
]
: [],
[unknown]
>
OmitTuple<function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>T, function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(indices: I): (self: T) => OmitTuple<T, I[number]>I[number]>
<const function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>T extends interface ReadonlyArray<T>ReadonlyArray<unknown>, const function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>I extends interface ReadonlyArray<T>ReadonlyArray<type Indices<
T extends ReadonlyArray<unknown>
> = Partial<T>["length"] extends T["length"]
? never
: Partial<T>["length"]
Indices<function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>T>>>(
self: const T extends ReadonlyArray<unknown>self: function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>T,
indices: const I extends ReadonlyArray<Indices<T>>indices: function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>I
): type OmitTuple<
T extends ReadonlyArray<unknown>,
K
> = 0 extends T["length"]
? []
: _BuildTuple<
T,
Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
>,
0 extends Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
>
? [
T[Exclude<
Exclude<
Partial<T>["length"],
T["length"]
>,
K
> &
0]
]
: [],
[unknown]
>
OmitTuple<function (type parameter) T in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>T, function (type parameter) I in <const T extends ReadonlyArray<unknown>, const I extends ReadonlyArray<Indices<T>>>(self: T, indices: I): OmitTuple<T, I[number]>I[number]>
} = import dualdual(
2,
<const function (type parameter) T in <const T extends ReadonlyArray<unknown>>(self: T, indices: ReadonlyArray<number>): unknown[]T extends interface ReadonlyArray<T>ReadonlyArray<unknown>>(
self: const T extends ReadonlyArray<unknown>self: function (type parameter) T in <const T extends ReadonlyArray<unknown>>(self: T, indices: ReadonlyArray<number>): unknown[]T,
indices: readonly number[]indices: interface ReadonlyArray<T>ReadonlyArray<number>
) => {
const const toDrop: Set<number>toDrop = new var Set: SetConstructor
new <number>(iterable?: Iterable<number> | null | undefined) => Set<number> (+1 overload)
Set<number>(indices: readonly number[]indices)
return self: const T extends ReadonlyArray<unknown>self.ReadonlyArray<unknown>.filter(predicate: (value: unknown, index: number, array: readonly unknown[]) => unknown, thisArg?: any): unknown[] (+1 overload)Returns the elements of an array that meet the condition specified in a callback function.
filter((_: unknown_, i: numberi) => !const toDrop: Set<number>toDrop.Set<number>.has(value: number): booleanhas(i: numberi))
}
)