type PredicateType = (value: T, index?: number, list?: T[]) => boolean; declare class List { protected _elements: T[]; /** * Make the List iterable and Spreadable */ [Symbol.iterator](): Generator; /** * property represents the Object name */ get [Symbol.toStringTag](): string; /** * Defaults the elements of the list */ constructor(elements?: T[]); /** * Adds an object to the end of the List. */ Add(element: T): void; /** * Appends an object to the end of the List. */ Append(element: T): void; /** * Add an object to the start of the List. */ Prepend(element: T): void; /** * Adds the elements of the specified collection to the end of the List. */ AddRange(elements: T[]): void; /** * Applies an accumulator function over a sequence. */ Aggregate(accumulator: (accum: U, value: T, index: number, list?: T[]) => any, initialValue: U): any; /** * Determines whether all elements of a sequence satisfy a condition. */ All(predicate: PredicateType): boolean; /** * Determines whether a sequence contains any elements. */ Any(predicate?: PredicateType): boolean; /** * Computes the average of a sequence of number values that are obtained by invoking * a transform function on each element of the input sequence. */ Average(transform?: (value?: T, index?: number, list?: T[]) => any): number; /** * Casts the elements of a sequence to the specified type. */ Cast(): List; /** * Removes all elements from the List. */ Clear(): void; /** * Concatenates two sequences. */ Concat(list: List): List; /** * Determines whether an element is in the List. */ Contains(element: T): boolean; /** * Returns the number of elements in a sequence. */ Count(predicate?: PredicateType): number; /** * Returns the elements of the specified sequence or the type parameter's default value * in a singleton collection if the sequence is empty. */ DefaultIfEmpty(defaultValue?: T): List; /** * Returns distinct elements from a sequence by using the default equality comparer to compare values. */ Distinct(): List; /** * Returns distinct elements from a sequence according to specified key selector. */ DistinctBy(keySelector: (key: T) => string | number): List; /** * Returns the element at a specified index in a sequence. */ ElementAt(index: number): T; /** * Returns the element at a specified index in a sequence or a default value if the index is out of range. */ ElementAtOrDefault(index: number): T | null; /** * Produces the set difference of two sequences by using the default equality comparer to compare values. */ Except(source: List): List; /** * Returns the first element of a sequence. */ First(predicate?: PredicateType): T; /** * Returns the first element of a sequence, or a default value if the sequence contains no elements. */ FirstOrDefault(defaultValue: T): T; /** * Performs the specified action on each element of the List. */ ForEach(action: (value?: T, index?: number, list?: T[]) => any): void; /** * Groups the elements of a sequence according to a specified key selector function. */ GroupBy(grouper: (key: T) => string | number, mapper?: (element: T) => TResult): { [key: string]: TResult[]; }; /** * Correlates the elements of two sequences based on equality of keys and groups the results. * The default equality comparer is used to compare keys. */ GroupJoin(list: List, key1: (k: T) => any, key2: (k: U) => any, result: (first: T, second: List) => R): List; /** * Returns the index of the first occurence of an element in the List. */ IndexOf(element: T): number; /** * Inserts an element into the List at the specified index. */ Insert(index: number, element: T): void | Error; /** * Produces the set intersection of two sequences by using the default equality comparer to compare values. */ Intersect(source: List): List; /** * Correlates the elements of two sequences based on matching keys. The default equality comparer is used to compare keys. */ Join(list: List, key1: (key: T) => any, key2: (key: U) => any, result: (first: T, second: U) => R): List; /** * Returns the last element of a sequence. */ Last(predicate?: PredicateType): T; /** * Returns the last element of a sequence, or a default value if the sequence contains no elements. */ LastOrDefault(defaultValue: T): T; private static readonly comparers; /** * Retrieves a default comparer function based on the type of the provided sample value. * Only supports primitive types: number, string, and boolean. * * @param sample - A sample value used to determine its type. * @returns A comparison function suitable for the type of the sample, or undefined if unsupported. */ private static getComparer; /** * Gets the maximum value in a generic sequence. * @returns The maximum value in the sequence, or undefined if the sequence is empty. */ Max(): T | undefined; /** * Gets the maximum value in a generic sequence. * @returns The maximum value in the sequence, or undefined if the sequence is empty. * @param selector - A function to select a value from each element for comparison. */ Max(selector: (e: T) => R): R | undefined; /** * Gets the maximum value in a generic sequence. * @returns The maximum value in the sequence, or undefined if the sequence is empty. * @param comparer - A custom comparison function */ Max(comparer: (a: T, b: T) => number): T | undefined; /** * Returns the maximum value in a generic sequence. * @param elements - The array of elements to find the maximum from. * @param customComparer - An optional custom comparison function. */ private getMaxElement; /** * Gets the minimum value in a generic sequence. * @returns The minimum value in the sequence, or undefined if the sequence is empty. */ Min(): T | undefined; /** * Gets the minimum value in a generic sequence. * @returns The minimum value in the sequence, or undefined if the sequence is empty. * @param selector - A function to select a value from each element for comparison. */ Min(selector: (e: T) => R): R | undefined; /** * Gets the minimum value in a generic sequence. * @returns The minimum value in the sequence, or undefined if the sequence is empty. * @param comparer - A custom comparison function */ Min(comparer: (a: T, b: T) => number): T | undefined; /** * Returns the minimum value in a generic sequence. * @param elements - The array of elements to find the minimum from. * @param customComparer - An optional custom comparison function. */ private getMinElement; /** * Filters the elements of a sequence based on a specified type. */ OfType(type: any): List; /** * Sorts the elements of a sequence in ascending order according to a key. */ OrderBy(keySelector: (key: T) => any, comparer?: (a: T, b: T) => number): List; /** * Sorts the elements of a sequence in descending order according to a key. */ OrderByDescending(keySelector: (key: T) => any, comparer?: (a: T, b: T) => number): List; /** * Performs a subsequent ordering of the elements in a sequence in ascending order according to a key. */ ThenBy(keySelector: (key: T) => any): List; /** * Performs a subsequent ordering of the elements in a sequence in descending order, according to a key. */ ThenByDescending(keySelector: (key: T) => any): List; /** * Removes the first occurrence of a specific object from the List. */ Remove(element: T): boolean; /** * Removes all the elements that match the conditions defined by the specified predicate. */ RemoveAll(predicate: PredicateType): List; /** * Removes the element at the specified index of the List. */ RemoveAt(index: number): void; /** * Reverses the order of the elements in the entire List. */ Reverse(): List; /** * Projects each element of a sequence into a new form. */ Select(selector: (element: T, index: number) => TOut): List; /** * Projects each element of a sequence to a List and flattens the resulting sequences into one sequence. */ SelectMany>(selector: (element: T, index: number) => TOut): TOut; /** * Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type. */ SequenceEqual(list: List): boolean; /** * Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. */ Single(predicate?: PredicateType): T; /** * Returns the only element of a sequence, or a default value if the sequence is empty; * this method throws an exception if there is more than one element in the sequence. */ SingleOrDefault(defaultValue: T): T; /** * Bypasses a specified number of elements in a sequence and then returns the remaining elements. */ Skip(amount: number): List; /** * Omit the last specified number of elements in a sequence and then returns the remaining elements. */ SkipLast(amount: number): List; /** * Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. */ SkipWhile(predicate: PredicateType): List; /** * Computes the sum of the sequence of number values that are obtained by invoking * a transform function on each element of the input sequence. */ Sum(transform?: (value?: T, index?: number, list?: T[]) => number): number; /** * Returns a specified number of contiguous elements from the start of a sequence. */ Take(amount: number): List; /** * Returns a specified number of contiguous elements from the end of a sequence. */ TakeLast(amount: number): List; /** * Returns elements from a sequence as long as a specified condition is true. */ TakeWhile(predicate: PredicateType): List; /** * Copies the elements of the List to a new array. */ ToArray(): T[]; /** * Creates a Dictionary from a List according to a specified key selector function. */ ToDictionary(key: (key: T) => TKey, value?: (value: T) => TValue): List<{ Key: TKey; Value: T | TValue; }>; /** * Creates a List from an Enumerable.List. */ ToList(): List; /** * Creates a Lookup from an IEnumerable according to specified key selector and element selector functions. */ ToLookup(keySelector: (key: T) => string | number, elementSelector: (element: T) => TResult): { [key: string]: TResult[]; }; /** * Produces the set union of two sequences by using the default equality comparer. */ Union(list: List): List; /** * Filters a sequence of values based on a predicate. */ Where(predicate: PredicateType): List; /** * Applies a specified function to the corresponding elements of two sequences, producing a sequence of the results. */ Zip(list: List, result: (first: T, second: U) => TOut): List; } export default List;