(
array: T[] | ReadonlyArray<T>,
fn: (item: T) => boolean
)
| 48 | } |
| 49 | |
| 50 | export function firstIndex<T>( |
| 51 | array: T[] | ReadonlyArray<T>, |
| 52 | fn: (item: T) => boolean |
| 53 | ): number { |
| 54 | for (let i = 0; i < array.length; i++) { |
| 55 | const element = array[i]; |
| 56 | |
| 57 | if (fn(element)) { |
| 58 | return i; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | return -1; |
| 63 | } |
| 64 | |
| 65 | export function remove<T>(array: T[], value: T): boolean { |
| 66 | const index = array.findIndex((t) => t === value); |
no outgoing calls
no test coverage detected
searching dependent graphs…