UNPKG
@twilio-paste/paste-reakit-fork
Version:
latest (1.4.1)
1.4.1
Forked Reakit that addresses SSR hydration issues
twilio-labs/paste-reakit
@twilio-paste/paste-reakit-fork
/
src
/
Composite
/
__utils
/
addItemAtIndex.ts
11 lines
(10 loc)
•
228 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
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)]; }