UNPKG

tsbase

Version:

Base class libraries for TypeScript

77 lines (76 loc) 3.08 kB
export declare class Queryable<T> extends Array<T> { protected constructor(); static From<T>(items: Array<T>): Queryable<T>; /** * Returns a copy of the array shuffled based on the knuth shuffle algorithm */ Shuffle(): Queryable<T>; /** * Returns all elements except for the set specified. * @param items */ Except(items: Array<T>): Queryable<T>; /** * Returns a random item from the array based on Knuth shuffle * @param excluding - optionally exclude an array of items when selecting a random element */ GetRandom(excluding?: Array<T>): T | null; /** * Sorts the elements of a sequence in ascending order based on the default comparer or user defined function(s) * @param funcs */ OrderBy(funcs?: Array<(item: T) => number | string>): Queryable<T>; /** * Sorts the elements of a sequence in descending order. * @param func */ OrderByDescending(funcs?: Array<(item: T) => number | string>): Queryable<T>; /** * Returns the first element of a sequence or null if the sequence is empty. * @param func optionally retrieve the first element which satisfies the given predicate */ First(func?: (item: T) => boolean): T | null; /** * Returns the last element of a sequence or null if the sequence is empty. * @param func optionally retrieve the last element which satisfies the given predicate */ Last(func?: (item: T) => boolean): T | null; /** * Returns the element with the minimum value in a sequence of values. * @param func */ Min(func?: (item: T) => any): T | null; /** * Returns the element with the maximum value in a sequence of values. * @param func */ Max(func?: (item: T) => any): T | null; /** * Computes the sum of a sequence of numeric values, or the sum result of the given function * @param func */ Sum(func?: (item: T) => number): number | null; /** * Computes the average of a sequence of numeric values, or the average result of the given function * @param func */ Average(func?: (item: T) => number): number | null; /** * Returns distinct elements from a sequence. * @param func */ Distinct(): Queryable<T>; /** * Perform a full text search on a collection for a given search term. Elements containing the entire search term * are given precedence over keyword matches. * @param term The term being searched for * @param minimumKeywordLength Keywords in the search term with a length less than this won't be considered * @param stopWords Keywords matching these words are not considered * @param ignorableSuffixCharacters Characters that should not prevent a positive match * (i.e. allows toy's' to match on toy) */ Search(term: string, minimumKeywordLength?: number, stopWords?: string[], ignorableSuffixCharacters?: string[]): Queryable<T>; private getKeywordsForTerm; private getKeywordMatches; private mutableArrayQuery; }