Skip to content

remove

Removes an item from an array

Usage

ts
import { remove } from 'tsu'

remove(['a', 'b', 'c', 'd', 'e'], 'c')
// ['a', 'b', 'd', 'e']

remove([{ animal: 'frog' }, { animal: 'toad' }], (item) => item.animal === 'toad')
// [{ animal: 'frog' }]

Type Definitions

ts
/**
 * @param array - The array.
 * @param item - The item, or getter function for the item, to remove.
 * @returns The array with the item removed, if found.
 */
function remove<T>(array: T[], itemOrGetter: T | ((item: T) => boolean)): T[]

Released under the MIT License.