Skip to content

indexesOf

Finds the positions in an array where any of the given items sit.

Usage

ts
import { indexesOf } from 'tsu'

indexesOf(['a', 'b', 'c', 'd', 'e'], ['b', 'e'])
// [1, 4]

indexesOf([1, 2, 1, 3, 1], [1])
// [0, 2, 4] - every occurrence is found

indexesOf([1, 2, 3], [4])
// []

Type Definitions

ts
/**
 * @param array - The array.
 * @param find - The items to find.
 * @returns The index of every item found.
 */
function indexesOf<T>(array: readonly T[], find: readonly T[]): number[]

Released under the MIT License.