type Push = (...args: Parameters["push"]>) => void; type Pop = () => void; type Unshift = (...args: Parameters["unshift"]>) => void; type Shift = () => void; type Reverse = () => void; type Concat = (value: T[]) => void; type Fill = (value: T, start?: number, end?: number) => void; type UpdateItemAtIndex = (index: number, value: T) => void; type Clear = () => void; type SetArray = (value: T[]) => void; type Splice = (...args: Parameters["splice"]>) => void; type RemoveItemAtIndex = (index: number) => void; type ReplaceItemAtIndex = (index: number, value: T) => void; type InsertItemAtIndex = (index: number, value: T) => void; type Sort = (compareFn?: (a: T, b: T) => number) => void; export type UseArrayStateControls = { push: Push; pop: Pop; clear: Clear; unshift: Unshift; shift: Shift; reverse: Reverse; concat: Concat; fill: Fill; updateItemAtIndex: UpdateItemAtIndex; setArray: SetArray; splice: Splice; removeItemAtIndex: RemoveItemAtIndex; replaceItemAtIndex: ReplaceItemAtIndex; insertItemAtIndex: InsertItemAtIndex; sort: Sort; }; export type UseArrayStateReturnValue = [T[], UseArrayStateControls]; /** * useArrayState * @description Array state manager hook for React * @param {Array} initialState Initial state of the array * @returns {UseArrayStateReturnValue} Array state manager hook for React * @see {@link https://rooks.vercel.app/docs/hooks/useArrayState} * * @example * * const [array, controls] = useArrayState([1, 2, 3]); * * controls.push(4); // [1, 2, 3, 4] * controls.pop(); // [1, 2, 3] * controls.unshift(0); // [0, 1, 2, 3] * controls.shift(); // [1, 2, 3] * controls.reverse(); // [3, 2, 1] * controls.concat([4, 5, 6]); // [3, 2, 1, 4, 5, 6] * controls.fill(0); // [0, 0, 0, 0, 0, 0] * controls.updateItemAtIndex(0, 1); // [1, 0, 0, 0, 0, 0] * controls.clear(); // [] * controls.setArray([1, 2, 3]); // [1, 2, 3] * controls.splice(1, 1); // [1, 3] * controls.removeItemAtIndex(1); // [1] * controls.replaceItemAtIndex(0, 2); // [2] * controls.insertItemAtIndex(0, 1); // [1, 2] * controls.sort((a, b) => a - b); // [1, 2] * */ declare function useArrayState(initial: T[] | (() => T[])): UseArrayStateReturnValue; export { useArrayState };