Array
arrRm

Removes items at the given index from the given array.

Immutable: This does not mutate the given array.

Syntax

import { arrRm } from '@opentf/std';
 
arrRm<T>(
  arr: T[] = [],
  index?: number,
  count: number = 1
)

Examples

arrRm([]) // => []);
 
arrRm([1]) // => []);
 
arrRm([1, 2]) // => [1]);
 
arrRm([1, 2], 1) // => [1]);
 
arrRm([1, 2], 1, 1) // => [1]);
 
arrRm([1, 2, 3, 4, 5], -1) // => [1, 2, 3, 4]);
 
arrRm([1, 2, 3, 4, 5], -1, 1) // => [1, 2, 3, 4]);
 
arrRm([1, 2, 3, 4, 5], -1, 3) // => [1, 2, 3, 4]);
 
arrRm([1, 2, 3, 4, 5], -2, 2) // => [1, 2, 3]);
 
const myFish = ['angel', 'clown', 'mandarin', 'sturgeon'];
arrRm(myFish, 2, Infinity) // => ['angel', 'clown']);

Try