added tests. bs tests, but tests

This commit is contained in:
Chris Kruining 2024-12-19 16:21:59 +01:00
parent c33e99b105
commit 1b18198022
No known key found for this signature in database
GPG key ID: EB894A3560CCCAD2
7 changed files with 168 additions and 13 deletions

View file

@ -39,10 +39,10 @@ export type Setter<T> =
export interface DataSet<T extends Record<string, any>> {
data: T[];
nodes: Accessor<DataSetNode<keyof T, T>[]>;
value: Accessor<(T | undefined)[]>;
mutations: Accessor<Mutation[]>;
sorting: Accessor<SortOptions<T> | undefined>;
grouping: Accessor<GroupOptions<T> | undefined>;
readonly value: (T | undefined)[];
readonly sorting: SortOptions<T> | undefined;
readonly grouping: GroupOptions<T> | undefined;
mutate<K extends keyof T>(index: number, prop: K, value: T[K]): void;
mutateEach(setter: (value: T) => T): void;
@ -107,10 +107,16 @@ export const createDataSet = <T extends Record<string, any>>(data: T[], initialO
const set: DataSet<T> = {
data,
nodes,
value: createMemo(() => state.value),
get value() {
return state.value;
},
mutations,
sorting,
grouping,
get sorting() {
return state.sorting;
},
get grouping() {
return state.grouping;
},
mutate(index, prop, value) {
setState('value', index, prop as any, value);