@byndyusoft-ui/use-array
Version:
Byndyusoft UI useArray React Hook
16 lines (15 loc) • 603 B
TypeScript
export type TUseArray<T> = [list: Array<T>, commands: IUseArrayCommands<T>];
export type TPredicate<T> = (value: T) => boolean;
export type TComparator<L, R> = (left: L, right: R) => number;
interface IUseArrayCommands<T> {
append: (item: T) => void;
prepend: (item: T) => void;
update: (index: number, item: T) => void;
remove: (index: number) => void;
filter: (predicate: TPredicate<T>) => void;
clear: () => void;
reset: () => void;
sort: (comparator: TComparator<T, T>) => void;
}
export default function useArray<T>(initialValue: Array<T>): TUseArray<T>;
export {};