Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EnumerableBase<T>

A basic sequence.

Type parameters

  • T

Hierarchy

Implements

Index

Properties

IS_ENUMERABLE

IS_ENUMERABLE: symbol = IS_ENUMERABLE

Indicates that that instance is an enumerable (sequence).

Protected _current

_current: IteratorResult<T>

Stores the current iterator result.

Protected _index

_index: number = -1

Stores the current index.

Accessors

canReset

  • get canReset(): boolean
  • Gets if that sequence can be resetted or not.

    inheritdoc

    Returns boolean

current

  • get current(): IteratorResult<T>
  • Gets the current iterator result.

    inheritdoc

    Returns IteratorResult<T>

index

  • get index(): number
  • Gets the current zero based index.

    inheritdoc

    Returns number

Methods

__@iterator

  • __@iterator(): Iterator<T>

abs

  • Handles current items as numbers and returns their absolute values.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

aggregate

  • aggregate<TAccumulate, TResult>(func: function, seed?: TAccumulate, resultSelector?: function): TResult
  • inheritdoc

    Type parameters

    • TAccumulate

    • TResult

    Parameters

    • func: function
        • (accumulator: TAccumulate, item: T): TAccumulate
        • Parameters

          • accumulator: TAccumulate
          • item: T

          Returns TAccumulate

    • Optional seed: TAccumulate
    • Optional resultSelector: function
        • (accumulator: TAccumulate): TResult
        • Parameters

          • accumulator: TAccumulate

          Returns TResult

    Returns TResult

all

  • Checks if all elements of that sequence satisfy a condition or not.

    Parameters

    Returns boolean

    All elements satisfy the condition or not.

any

  • Checks if at least one element of that sequence satisfies a condition or not.

    Parameters

    Returns boolean

    One element satisfies the condition or not.

append

appendArray

arcCos

  • Handles current items as numbers and calculates the arc cosine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

arcCosH

  • Handles current items as numbers and calculates the arc hyperbolic cosine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

arcSin

  • Handles current items as numbers and calculates the arc sine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

arcSinH

  • Handles current items as numbers and calculates the arc hyperbolic sine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

arcTan

  • Handles current items as numbers and calculates the arc tangent for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

arcTanH

  • Handles current items as numbers and calculates the arc hyperbolic tangent for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

assert

  • Asserts that all elements of that sequence meet a given condition, otherwise an error is throw at first fail.

    chainable
    throws

    One element failed.

    Parameters

    Returns this

assertAll

  • Asserts that all elements of that sequence meet a given condition, otherwise an error is throw at the end.

    chainable
    throws

    At least one element failed.

    Parameters

    Returns this

async

  • async(action: AsyncAction<T>, previousValue?: any): Promise<any>
  • Runs an async action for each item of that sequence.

    Parameters

    Returns Promise<any>

    The promise.

average

  • average(selector?: Selector<T, number>): number | symbol
  • Calculates the average of the items of that sequence.

    Parameters

    • Optional selector: Selector<T, number>

    Returns number | symbol

    The average or IS_EMPTY if sequence is empty.

cast

  • Returns a "casted" version of that sequence.

    template

    U The target type.

    throws

    Target type is not supported

    Type parameters

    • U

    Parameters

    • Optional type: string

    Returns IEnumerable<U>

    The "casted" sequence.

ceil

  • Handles current items as float values and returns the smallest value greater than or equal to them.

    Returns IEnumerable<number>

    The new sequence.

chunk

Protected chunkInner

  • chunkInner(size: number): IterableIterator<IEnumerable<T>>

clone

  • Clones that sequence multiply times.

    template

    U The type of the target sequences.

    Type parameters

    • U

    Parameters

    • Optional count: number
    • Optional itemSelector: Selector<T, U>

    Returns IEnumerable<IEnumerable<U>>

    The sequence of sequences.

Protected cloneInner

  • cloneInner<U>(count: number, itemSelector: Selector<T, U>): IterableIterator<any>
  • see

    concatArray()

    Type parameters

    • U

    Parameters

    • count: number
    • itemSelector: Selector<T, U>

    Returns IterableIterator<any>

concat

  • Concats the items of that sequences with other ones to a new sequence.

    memberof

    IEnumerable<T|U> The concated sequence.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<T | U>

concatArray

  • Concats the items of that sequences with other ones to a new sequence.

    memberof

    IEnumerable<T|U> The concated sequence.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<T | U>

Protected concatArrayInner

  • concatArrayInner<U>(sequences: ArrayLike<Sequence<U>>): IterableIterator<T | U>
  • see

    concatArray()

    Type parameters

    • U

    Parameters

    Returns IterableIterator<T | U>

consume

  • consume(): this
  • Completely consumes the given sequence. This method uses immediate execution, and doesn't store any data during execution.

    chainable

    Returns this

contains

  • Checks if that sequence contains an item.

    template

    U Type of the item to search for.

    Type parameters

    • U

    Parameters

    Returns boolean

    Sequence contains item or not.

cos

  • Handles current items as numbers and calculates the cosine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

cosH

  • Handles current items as numbers and calculates the hyperbolic cosine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

count

  • Counts the elements of that sequence.

    Parameters

    Returns number

    The number of (matching) items.

defaultArrayIfEmpty

defaultIfEmpty

  • defaultIfEmpty(...defaultItems: Array<T>): IEnumerable<T>

Protected defaultIfEmptyInner

  • defaultIfEmptyInner(defaultItems: Array<T>): IterableIterator<T>
  • see

    defaultIfEmpty()

    Parameters

    • defaultItems: Array<T>

    Returns IterableIterator<T>

defaultSequenceIfEmpty

Protected defaultSequenceIfEmptyInner

  • defaultSequenceIfEmptyInner(defaultSequence: Sequence<T>): IterableIterator<T>
  • see

    defaultIfEmpty()

    Parameters

    Returns IterableIterator<T>

distinct

distinctBy

Protected distinctByInner

each

eachAll

elementAt

  • elementAt(index: number): T
  • Returns an element at a specific index.

    throws

    Element not found.

    Parameters

    • index: number

    Returns T

    The element.

elementAtOrDefault

  • elementAtOrDefault<U>(index: number, defaultValue?: U): T | U
  • Returns an element at a specific index.

    template

    U Type of the default value.

    throws

    Element not found.

    Type parameters

    • U

    Parameters

    • index: number
    • Optional defaultValue: U

    Returns T | U

    The element.

except

Protected exceptInner

  • exceptInner(second: Array<T>, comparer: EqualityComparer<T>): IterableIterator<T>

exp

  • Handles current items as numbers and calculates e (the base of natural logarithms) raised to each value.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

first

  • Returns the first element of that sequence.

    throws

    Element not found.

    Parameters

    Returns T

    The first element.

firstOrDefault

  • firstOrDefault<U>(predicateOrDefaultValue?: Predicate<T> | T, defaultValue?: U): T | U
  • Tries to return the first element.

    template

    U Type of the default value.

    Type parameters

    • U

    Parameters

    • Optional predicateOrDefaultValue: Predicate<T> | T
    • Optional defaultValue: U

    Returns T | U

    The item or the default value.

flatten

  • Returns a flattened sequence that contains the concatenation of all the nested sequences elements.

    Type parameters

    • U

    Returns IEnumerable<U>

    The flatten items.

floor

  • Handles current items as float values and return the greatest value less than or equal to them.

    Returns IEnumerable<number>

    The new sequence.

forAll

  • Invokes a function for each element of that sequence and continues even if an error is thrown. All occurred errors will be thrown at the end.

    throws

    At least on error was thrown while the execution.

    chainable

    Parameters

    Returns this

forEach

Protected getNextChunkArray

  • getNextChunkArray(size: number): T[]
  • see

    chunkInner()

    Parameters

    • size: number

    Returns T[]

groupBy

Protected groupByInner

groupJoin

  • groupJoin<TInner, TOuterKey, TInnerKey, TResult>(inner: Sequence<TInner>, outerKeySelector?: Selector<T, TOuterKey>, innerKeySelector?: Selector<TInner, TInnerKey>, resultSelector?: function, keyEqualityComparer?: EqualityComparer<TOuterKey, TInnerKey> | true): IEnumerable<TResult>
  • inheritdoc

    Type parameters

    • TInner

    • TOuterKey

    • TInnerKey

    • TResult

    Parameters

    • inner: Sequence<TInner>
    • Optional outerKeySelector: Selector<T, TOuterKey>
    • Optional innerKeySelector: Selector<TInner, TInnerKey>
    • Optional resultSelector: function
        • Parameters

          Returns TResult

    • Optional keyEqualityComparer: EqualityComparer<TOuterKey, TInnerKey> | true

    Returns IEnumerable<TResult>

Protected groupJoinInner

  • groupJoinInner<TInner, TOuterKey, TInnerKey, TResult>(inner: IEnumerable<TInner>, outerKeySelector: Selector<T, TOuterKey>, innerKeySelector: Selector<TInner, TInnerKey>, resultSelector: function, keyEqualityComparer: EqualityComparer<TOuterKey, TInnerKey>): IterableIterator<TResult>
  • see

    groupJoin()

    Type parameters

    • TInner

    • TOuterKey

    • TInnerKey

    • TResult

    Parameters

    Returns IterableIterator<TResult>

indexOf

  • Returns the zero based index of the first occurrence of an item.

    template

    U Type of the item to search for.

    Type parameters

    • U

    Parameters

    Returns number

    The index or -1 if not found.

intersect

Protected intersectInner

  • intersectInner(second: Array<T>, comparer: EqualityComparer<T>): IterableIterator<T>

intersperse

  • intersperse<U>(...separators: U[]): IEnumerable<T | U>
  • Returns all elements of the collection separated by the given separator(s).

    Type parameters

    • U

    Parameters

    • Rest ...separators: U[]

    Returns IEnumerable<T | U>

    The new sequence.

intersperseArray

Protected intersperseInner

  • intersperseInner<U>(separators: U[]): Iterator<T | U>
  • see

    intersperseInner()

    Type parameters

    • U

    Parameters

    • separators: U[]

    Returns Iterator<T | U>

isEmpty

  • isEmpty(): boolean
  • Checks if that sequence is empty or not by using the length() method.

    Returns boolean

    Is Empty or not.

join

  • join<TInner, TOuterKey, TInnerKey, TResult>(inner: Sequence<TInner>, outerKeySelector?: Selector<T, TOuterKey>, innerKeySelector?: Selector<TInner, TInnerKey>, resultSelector?: function, keyEqualityComparer?: EqualityComparer<TOuterKey, TInnerKey> | true): IEnumerable<TResult>
  • inheritdoc

    Type parameters

    • TInner

    • TOuterKey

    • TInnerKey

    • TResult

    Parameters

    • inner: Sequence<TInner>
    • Optional outerKeySelector: Selector<T, TOuterKey>
    • Optional innerKeySelector: Selector<TInner, TInnerKey>
    • Optional resultSelector: function
        • (outer: T, inner: TInner): TResult
        • Parameters

          • outer: T
          • inner: TInner

          Returns TResult

    • Optional keyEqualityComparer: EqualityComparer<TOuterKey, TInnerKey> | true

    Returns IEnumerable<TResult>

Protected joinInner

  • joinInner<TInner, TOuterKey, TInnerKey, TResult>(inner: IEnumerable<TInner>, outerKeySelector: Selector<T, TOuterKey>, innerKeySelector: Selector<TInner, TInnerKey>, resultSelector: function, keyEqualityComparer: EqualityComparer<TOuterKey, TInnerKey>): IterableIterator<TResult>
  • see

    join()

    Type parameters

    • TInner

    • TOuterKey

    • TInnerKey

    • TResult

    Parameters

    • inner: IEnumerable<TInner>
    • outerKeySelector: Selector<T, TOuterKey>
    • innerKeySelector: Selector<TInner, TInnerKey>
    • resultSelector: function
        • (outer: T, inner: TInner): TResult
        • Parameters

          • outer: T
          • inner: TInner

          Returns TResult

    • keyEqualityComparer: EqualityComparer<TOuterKey, TInnerKey>

    Returns IterableIterator<TResult>

joinToString

  • joinToString(separator?: any): string
  • Joins the items of that sequence to one string.

    Parameters

    • Optional separator: any

    Returns string

    The items as string.

last

  • Returns the last element of that sequence.

    throws

    Element not found.

    Parameters

    Returns T

    The last element.

lastIndexOf

  • Returns the zero based index of the last occurrence of an item.

    template

    U Type of the item to search for.

    Type parameters

    • U

    Parameters

    Returns number

    The index or -1 if not found.

lastOrDefault

  • lastOrDefault<U>(predicateOrDefaultValue?: Predicate<T> | T, defaultValue?: U): T | U
  • Tries to return the last element.

    template

    U Type of the default value.

    Type parameters

    • U

    Parameters

    • Optional predicateOrDefaultValue: Predicate<T> | T
    • Optional defaultValue: U

    Returns T | U

    The item or the default value.

length

  • length(): number
  • Returns the length of the underlying collection. If the underlying object does NOT contain a 'length' property, like a generator, it will behave the same way as 'count' method.

    Returns number

    The length.

log

  • log(base?: number, handleAsInt?: boolean): IEnumerable<number>
  • Handles current items as numbers and calculates the logarithm of them.

    Parameters

    • Optional base: number
    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

makeResettable

max

  • Returns the maximum item of that sequence.

    Type parameters

    • U

    Parameters

    Returns T | symbol

    The item or IS_EMPTY if that sequence is empty.

min

  • Returns the minimum item of that sequence.

    Type parameters

    • U

    Parameters

    Returns T | symbol

    The item or IS_EMPTY if that sequence is empty.

Abstract next

  • next(value?: any): IteratorResult<T>

noNAN

not

  • Filters the items of that sequence based on a given predicate and returns those items that do not match the predicate.

    Parameters

    Returns IEnumerable<T>

    The filtered sequence.

notEmpty

ofType

  • Filters items of specific type.

    template

    U The type of the target sequence.

    Type parameters

    • U

    Parameters

    • type: string

    Returns IEnumerable<U>

    The filtered sequence.

order

orderBy

orderByDescending

orderDescending

pipe

Protected pipeInner

pow

  • pow(exponent?: number, handleAsInt?: boolean): IEnumerable<number>
  • Handles current items as base numbers and take them to a specific power.

    Parameters

    • Optional exponent: number
    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

prepend

  • Prepends the itms of other sequences to the ones of that sequence.

    memberof

    IEnumerable<T|U> The concated sequence.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<T | U>

prependArray

  • Prepends the itms of other sequences to the ones of that sequence.

    memberof

    IEnumerable<T|U> The concated sequence.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<T | U>

Protected prependArrayInner

  • prependArrayInner<U>(sequences: ArrayLike<Sequence<U>>): IterableIterator<T | U>
  • see

    concatArray()

    Type parameters

    • U

    Parameters

    Returns IterableIterator<T | U>

product

  • product(): T | symbol

pushTo

  • pushTo(stack: Stack<T>): this

rand

reset

  • reset(): this

reverse

root

  • root(power?: number, handleAsInt?: boolean): IEnumerable<number>
  • Handles current items as numbers and calculates the n-th root for each item.

    Parameters

    • Optional power: number
    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

round

select

  • Projects the items of that sequence to new values / objects.

    template

    U The type of the new items.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<U>

    The new sequence.

selectMany

  • Projects the items of that sequence to new sequences that are flatten to a single sequence.

    template

    U Type of the items of the result sequences.

    Type parameters

    • U

    Parameters

    Returns IEnumerable<U>

    The new, flatten sequence.

Protected selectManyInner

sequenceEqual

  • Checks if that sequence is equal to another.

    template

    U Type of the items of the other sequence.

    Type parameters

    • U

    Parameters

    Returns boolean

    Both are equal or not.

shuffle

  • shuffle(sortValueProvider?: function): any
  • inheritdoc

    Parameters

    • Optional sortValueProvider: function
        • (): any
        • Returns any

    Returns any

sin

  • Handles current items as numbers and calculates the sine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

sinH

  • Handles current items as numbers and calculates the hyperbolic sine for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

single

  • Returns the one and only element of that sequence.

    throws

    Element not found or sequence contains for than one (matching) element.

    Parameters

    Returns T

    The single element.

singleOrDefault

  • singleOrDefault<U>(predicateOrDefaultValue?: Predicate<T> | T, defaultValue?: U): T | U
  • Tries to return the one and only element.

    template

    U Type of the default value.

    throws

    Sequence contains for than one (matching) element.

    Type parameters

    • U

    Parameters

    • Optional predicateOrDefaultValue: Predicate<T> | T
    • Optional defaultValue: U

    Returns T | U

    The item or the default value.

skip

skipLast

Protected skipLastInner

  • skipLastInner(): IterableIterator<T>
  • see

    skipLast()

    Returns IterableIterator<T>

skipWhile

Protected skipWhileInner

  • skipWhileInner(predicate: Predicate<T>): IterableIterator<T>

sqrt

  • Handles current items as numbers and calculates square root for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

sum

  • sum(): T | symbol

take

takeWhile

Protected takeWhileInner

  • takeWhileInner(predicate: Predicate<T>): IterableIterator<T>

tan

  • Handles current items as numbers and calculates the tangent for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

tanH

  • Handles current items as numbers and calculates the hyperbolic tangent for each item.

    Parameters

    • Optional handleAsInt: boolean

    Returns IEnumerable<number>

    The new sequence.

toArray

  • toArray(): Array<T>
  • Creates a new array from the items of that sequence.

    Returns Array<T>

    The sequence as array.

toLookup

  • Converts that sequence to a lookup object.

    template

    TKey Type of the keys.

    template

    U Type of the result object.

    Type parameters

    • TKey: PropertyKey

    • U

    Parameters

    Returns U

    U The lookup object

toObject

  • toObject<TResult, TKey>(keySelector?: function): TResult
  • inheritdoc

    Type parameters

    • TResult

    • TKey: PropertyKey

    Parameters

    • Optional keySelector: function
        • (item: T, index: number): TKey
        • Parameters

          • item: T
          • index: number

          Returns TKey

    Returns TResult

trace

union

where

Protected whereInner

  • whereInner(predicate: Predicate<T>): IterableIterator<T>

zip

  • Applies a specified function to the corresponding elements of that sequence and another, producing a sequence of the results.

    template

    U Type of the other sequence.

    template

    TResult The result type.

    Type parameters

    • U

    • TResult

    Parameters

    Returns IEnumerable<TResult>

    The "zipped" sequence.

Protected zipInner

  • zipInner<U, TResult>(second: Iterator<U>, resultSelector: ZipSelector<T, U, TResult>): IterableIterator<TResult>
  • see

    zip()

    Type parameters

    • U

    • TResult

    Parameters

    • second: Iterator<U>
    • resultSelector: ZipSelector<T, U, TResult>

    Returns IterableIterator<TResult>

Generated using TypeDoc