UNPKG

reakit

Version:

Toolkit for building accessible rich web apps with React

11 lines (10 loc) 228 B
export function addItemAtIndex<T extends any[]>( array: T, item: T[number], index: number ) { if (!(index in array)) { return [...array, item]; } return [...array.slice(0, index), item, ...array.slice(index)]; }