From 725edad3e1b0aa300a64b3e4b15f89392adf6681 Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Wed, 30 Oct 2024 09:32:03 +0700 Subject: [PATCH] feat: add util for array management --- src/utils/arr.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/utils/arr.ts diff --git a/src/utils/arr.ts b/src/utils/arr.ts new file mode 100644 index 00000000..2a264ad9 --- /dev/null +++ b/src/utils/arr.ts @@ -0,0 +1,11 @@ +export function removeAt(arr: T, idx: number) { + return arr.splice(idx, 1); +} + +export function insertAt( + arr: T, + idx: number, + item: T[number], +) { + return arr.splice(idx, 0, item); +}