Module:FunList/EnumerableExtensions/doc

From Melvor Idle
< Module:FunList‎ | EnumerableExtensions
Revision as of 20:02, 26 July 2024 by Ricewind (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:FunList/EnumerableExtensions

Contains all shorthand functions that convert one Enumerable object into another. Most of these functions can be chained together to result in a state machine that captures all of the applied functions. The state machine is only executed once a pairs or ipairs operator is applied to the state machine, or by manually progressing the Module:FunList/Enumerator.


Functions

all

-- Determines whether all elements of a sequence satisfy a condition.
---@param self Enumerable
---@param predicate fun(item: any): boolean
---@return boolean
function Enumerable:all(predicate)

any

-- Determines whether any element of a sequence exists or satisfies a condition.
---@param self Enumerable
---@param predicate fun(item: any): boolean
---@return boolean
function Enumerable:any(predicate)

append

-- Adds an item to the end of the enumerable.
---@param self Enumerable
---@param item any
function Enumerable:append(item)

prepend

-- Adds an item to the front of the enumerable.
---@param self Enumerable
---@param item any
function Enumerable:prepend(item)

contains

-- Determines whether a sequence contains a specified element.
---@param self Enumerable
---@param item any
---@return boolean
function Enumerable:contains(item)

count

-- Returns the number of elements in a sequence.
---@param self Enumerable
---@return integer
function Enumerable:count()

first

-- Returns the first element of a sequence.
---@param self Enumerable
---@param predicate? fun(item: any): boolean
---@return any
function Enumerable:first(predicate)

firstOrDefault

-- Returns the first element of a sequence, or a default value if no element is found.
---@param self Enumerable
---@param predicate? fun(item: any): boolean
---@param defaultItem? any
---@return any
function Enumerable:firstOrDefault(predicate, defaultItem)

last

-- Returns the last element of a sequence.
---@param self Enumerable
---@return any
function Enumerable:last()

lastOrDefault

-- Returns the last element of a sequence, or a default value if no element is found.
---@param self Enumerable
---@param defaultItem? any
---@return any
function Enumerable:lastOrDefault(defaultItem)

max

-- Returns the maximum value in a sequence of values.
---@param self Enumerable
---@return number
function Enumerable:max()

min

-- Returns the minimum value in a sequence of values.
---@param self Enumerable
---@return number
function Enumerable:min()

sum

-- Returns the sum value of a sequence of values.
function Enumerable:sum()

concat

-- Adds elements from one sequence to the other.
---@param self Enumerable
---@param other Enumerable
function Enumerable:concat(other)

difference

-- Gets the difference between two sequences
---@param self Enumerable
---@param other Enumerable
function Enumerable:difference(other)

differenceBy

-- Gets the difference between two sequences based on a key
---@param self Enumerable
---@param keySelector? fun(value: any, index: any): any
function Enumerable:differenceBy(other, keySelector)

flatMap

-- Maps items from one sequence to another.
---@param self Enumerable
---@param selector fun(value: any, index: integer): any
function Enumerable:flatMap(selector)

groupBy

--Groups the elements of a sequence.
---@param self Enumerable
---@param keySelector fun(param: any): any
---@param elementSelector? fun(param: any): any
function Enumerable:groupBy(keySelector, elementSelector)

groupByResult

--Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function.
---@param self Enumerable
---@param keySelector fun(param: any): any
---@param elementSelector? fun(param: any): any
---@param resultSelector fun(key: any, grouping: Grouping): any
function Enumerable:groupByResult(keySelector, elementSelector, resultSelector)

intersect

--Produces the set intersection of two sequences.
---@param self Enumerable
---@param other Enumerable
function Enumerable:intersect(other)

intersectBy

--Produces the set intersection of two sequences according to a specified key selector function.
---@param self Enumerable
---@param other Enumerable
---@param keySelector? fun(value: any, index: any): any
function Enumerable:intersectBy(other, keySelector)

map

--Projects each element of a sequence into a new form.
---@param self Enumerable
---@param selector fun(value: any, index: any): any
function Enumerable:map(selector)

sort

--Sorts a sequence.
---@param self Enumerable
---@return SortableIterator
function Enumerable:sort()

sortDescending

--Sorts a sequence in descending order.
---@param self Enumerable
---@return SortableIterator
function Enumerable:sortDescending()

sortBy

--Sorts a sequence based on a specified key selector function.
---@param self Enumerable
---@return SortableIterator
function Enumerable:sortBy(keySelector)

sortByDescending

--Sorts a sequence based on a specified key selector function in descending order.
---@param self Enumerable
---@return SortableIterator
function Enumerable:sortByDescending(keySelector)

thenSortBy

--Sorts a sorted sequence further based on a specified key selector function.
---@param self SortableIterator
---@return SortableIterator
function Enumerable:thenSortBy(keySelector)

thenSortByDescending

--Sorts a sorted sequence further based on a specified key selector function in descending order.
---@param self SortableIterator
---@return SortableIterator
function Enumerable:thenSortByDescending(keySelector)

union

--Produces the set union of two sequences according to a specified key selector function.
---@param self Enumerable
---@param other any
function Enumerable:union(other)

unionBy

--Produces the set union of two sequences according to a specified key selector function.
---@param self Enumerable
---@param other any
---@param keySelector? fun(value: any, index: any): any
function Enumerable:unionBy(other, keySelector)

unique

--Returns unique (distinct) elements from a sequence according to a specified key selector function. 
---@param self Enumerable
function Enumerable:unique()

uniqueBy

--Returns unique (distinct) elements from a sequence according to a specified key selector function. 
---@param self Enumerable
---@param keySelector? fun(value: any, index: any): any
function Enumerable:uniqueBy(keySelector)

where

--Filters a sequence of values based on a predicate.
---@param self Enumerable
---@param predicate fun(value: any, index: any): boolean
function Enumerable:where(predicate)

zip

--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence.
---@param self Enumerable
---@param other any
function Enumerable:zip(other)

zipBy

--Projects each element of a sequence to an Enumerable and flattens the resulting sequences into one sequence.
---@param self Enumerable
---@param other any
---@param resultSelector? fun(left: any, right: any): any
function Enumerable:zipBy(other, resultSelector)

toDictionary

---@param self Enumerable
---@param keySelector fun(item: any, index: any): any
---@param valueSelector fun(item: any, index: any): any
---@return table
function Enumerable:toDictionary(keySelector, valueSelector)

toTable

---@param self Enumerable
---@return table
function Enumerable:toTable()

toHashSet

---@param self Enumerable
---@return table
function Enumerable:toHashSet()