@kwiz/common
Version:
KWIZ common utilities and helpers for M365 platform
19 lines (18 loc) • 1.23 kB
TypeScript
import { IDictionary } from "../types/common.types";
import { IMultiLevelGroup } from "./collections.base";
/** check that every element in the arrays are the same value */
export declare function arraysEqual(arr1: any[], arr2: any[]): boolean;
/** Takes an array and transforms it into a dictionary. this will assign all items of the same key as an array. */
export declare function groupBy<T>(arr: T[], getKeys: (element: T) => string[], filter?: (element: T) => boolean): IDictionary<T[]>;
/** allows nested multi-level grouping */
export declare function GroupByMultiple<ItemType>(arr: ItemType[], groupDefinitions: {
/** return all groups this item belongs to */
getGroupsForThisElement: ((element: ItemType) => string[]);
/** Optional, add a prefix to the group. For example: "Priority > " to fullTitle will be "Priority > High" */
groupPrefix?: string;
}[], options?: {
filter?: (element: ItemType) => boolean;
/** if groups were calculated, they are returned from cache. send true to clear that cache. send true if you suspect getKeysCollection might change on your existing array. */
clearCache?: boolean;
parentGroup?: IMultiLevelGroup<ItemType>;
}): IDictionary<IMultiLevelGroup<ItemType>>;