@helpwave/hightide
Version:
helpwave's component and theming library
32 lines (30 loc) • 1.52 kB
text/typescript
declare const equalSizeGroups: <T>(array: T[], groupSize: number) => T[][];
type RangeOptions = {
/** Whether the range can be defined empty via end < start without a warning */
allowEmptyRange: boolean;
stepSize: number;
exclusiveStart: boolean;
exclusiveEnd: boolean;
};
/**
* @param endOrRange The end value or a range [start, end], end is exclusive
* @param options the options for defining the range
*/
declare const range: (endOrRange: number | [number, number], options?: Partial<RangeOptions>) => number[];
/** Finds the closest match
* @param list The list of all possible matches
* @param firstCloser Return whether item1 is closer than item2
*/
declare const closestMatch: <T>(list: T[], firstCloser: (item1: T, item2: T) => boolean) => T;
/**
* returns the item in middle of a list and its neighbours before and after
* e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]
*/
declare const getNeighbours: <T>(list: T[], item: T, neighbourDistance?: number) => T[];
declare const createLoopingListWithIndex: <T>(list: T[], startIndex?: number, length?: number, forwards?: boolean) => [number, T][];
declare const createLoopingList: <T>(list: T[], startIndex?: number, length?: number, forwards?: boolean) => T[];
declare const ArrayUtil: {
unique: <T>(list: T[]) => T[];
difference: <T>(list: T[], removeList: T[]) => T[];
};
export { ArrayUtil, type RangeOptions, closestMatch, createLoopingList, createLoopingListWithIndex, equalSizeGroups, getNeighbours, range };