diff --git a/src/index.tsx b/src/index.tsx index bcd23e6..76d304d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -69,6 +69,16 @@ export const useComplexState = >(initialValue: T[]) => { }); }; + const removeMany = (indexes: number[]) => { + const filteredValidIndexes = indexes.filter( + (index) => !isInvalidOrNegativeIndex(index, complexState) + ); + + setComplexState((prevState) => { + return prevState.filter((_, idx) => !filteredValidIndexes.includes(idx)); + }); + }; + return { value: complexState, setValue: setComplexState, @@ -77,5 +87,6 @@ export const useComplexState = >(initialValue: T[]) => { update, partialUpdate, remove, + removeMany, }; };