feat: add util for array management
This commit is contained in:
parent
e117ce999a
commit
725edad3e1
1 changed files with 11 additions and 0 deletions
11
src/utils/arr.ts
Normal file
11
src/utils/arr.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export function removeAt<T extends any[]>(arr: T, idx: number) {
|
||||
return arr.splice(idx, 1);
|
||||
}
|
||||
|
||||
export function insertAt<T extends any[]>(
|
||||
arr: T,
|
||||
idx: number,
|
||||
item: T[number],
|
||||
) {
|
||||
return arr.splice(idx, 0, item);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue