@humanspeak/svelte-headless-table
Version:
A powerful, headless table library for Svelte that provides complete control over table UI while handling complex data operations like sorting, filtering, pagination, grouping, and row expansion. Build custom, accessible data tables with zero styling opin
32 lines (31 loc) • 1.2 kB
TypeScript
/**
* Compares two values or arrays for sorting purposes.
* Returns a negative number if a < b, positive if a > b, and 0 if equal.
*
* @template T - The type of elements being compared (string or number).
* @param a - The first value or array to compare.
* @param b - The second value or array to compare.
* @returns A number indicating the sort order.
* @example
* ```typescript
* compare(1, 2) // Returns -1
* compare('b', 'a') // Returns 1
* compare([1, 2], [1, 3]) // Returns -1
* ```
*/
export declare const compare: <T extends string | number>(a: T | T[], b: T | T[]) => number;
/**
* Compares two arrays element by element for sorting purposes.
* Comparison stops at the first non-equal element.
*
* @template T - The type of elements in the arrays (string or number).
* @param a - The first array to compare.
* @param b - The second array to compare.
* @returns A number indicating the sort order based on the first differing element.
* @example
* ```typescript
* compareArray([1, 2, 3], [1, 2, 4]) // Returns -1
* compareArray(['a', 'b'], ['a', 'a']) // Returns 1
* ```
*/
export declare const compareArray: <T extends string | number>(a: T[], b: T[]) => number;