From b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Mon, 24 Nov 2025 20:54:57 +0100 Subject: Docs --- node_modules/thenby/thenBy.module.d.ts | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 node_modules/thenby/thenBy.module.d.ts (limited to 'node_modules/thenby/thenBy.module.d.ts') diff --git a/node_modules/thenby/thenBy.module.d.ts b/node_modules/thenby/thenBy.module.d.ts new file mode 100644 index 0000000..becb6d5 --- /dev/null +++ b/node_modules/thenby/thenBy.module.d.ts @@ -0,0 +1,51 @@ +// Type definitions for thenBy +// Definitions by: Teun Duynstee (with significant help from @HonoluluHenk) +type SortOrder = "asc" | "desc" | -1 | 1; +declare class opt { + direction?:SortOrder; + ignoreCase?:boolean; +} +declare class typedOpt extends opt { + cmp?: (a:T, b:T)=> number; +} +interface IThenBy { + (v1: T, v2: T) : number; + /** + * Full format to compare two elements and determine which sorts first. + * @param compare function that receives two values from the sorted array and returns a number indicating which comes first: < 0: first comes first, 0: doesn't matter, > 0: second comes first. + * @param direction can be used to reverse the sorting by passing -1 + **/ + thenBy(compare: ((v1: T, v2: T) => number), direction?: SortOrder | opt): IThenBy; + /** + * Shorthand for selecting a value to sort on from the sorted element. + * @param select function that receives a value from the sorted array and selects the thing to sort on + * @param direction reverse by passing -1. opt for other options + **/ + thenBy(select: ((v: T) => U), direction?: SortOrder | typedOpt): IThenBy; + /** + * Shorthand for sorting on a simple property. + * @param byPropertyName is the name of the property to sort on as a string + * @param direction reverse by passing -1. opt for other options + **/ + thenBy(byPropertyName: (keyof T), direction?: SortOrder | typedOpt): IThenBy; +} +declare module "thenby" { + /** + * Full format to compare two elements and determine which sorts first. + * @param compare function that receives two values from the sorted array and returns a number indicating which comes first: < 0: first comes first, 0: doesn't matter, > 0: second comes first. + * @param direction can be used to reverse the sorting by passing -1 + **/ + export function firstBy(compare: ((v1: T, v2: T) => number), direction?: SortOrder | opt): IThenBy; + /** + * Shorthand for selecting a value to sort on from the sorted element. + * @param select function that receives a value from the sorted array and selects the thing to sort on + * @param direction reverse by passing -1. opt for other options + **/ + export function firstBy(select: ((v: T) => U), direction?: SortOrder | typedOpt): IThenBy; + /** + * Shorthand for sorting on a simple property. + * @param byPropertyName is the name of the property to sort on as a string + * @param direction reverse by passing -1. opt for other options + **/ + export function firstBy(byPropertyName: (keyof T), direction?: SortOrder | typedOpt): IThenBy; + } -- cgit v1.2.3