Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Enumerable

Copyright (c) Marcel Joachim Kloubert marcel.kloubert@gmx.net

Index

Type aliases

AsyncAction

AsyncAction: function

An async action.

template

T Type of the underlying items.

param

The underlying context.

Type declaration

CancelableFactory

CancelableFactory: function

A factory function that can be cancelled.

template

TResult The type of the result.

param

The callback to cancel the operation.

param

The zero based index of that invocation.

returns

The result.

Type declaration

    • (cancel: function, index: number): TResult
    • Parameters

      • cancel: function
          • (flag?: boolean): void
          • Parameters

            • Optional flag: boolean

            Returns void

      • index: number

      Returns TResult

Comparer

Comparer: function

Compares to values.

template

T Type of the "left" value.

template

U Type of the "right" value.

param

The "left" value.

param

The "right" value.

returns

The "sort" value.

Type declaration

    • (x: T, y: U): number
    • Parameters

      • x: T
      • y: U

      Returns number

EachAction

EachAction: function

A forEach action.

template

T Type of the items.

param

The current item.

param

The zero based index of the current item.

Type declaration

    • (item: T, index: number): void
    • Parameters

      • item: T
      • index: number

      Returns void

EqualityComparer

EqualityComparer: function

Checks if two values are equal.

template

T Type of the "left" value.

template

U Type of the "right" value.

param

The "left" value.

param

The "right" value.

returns

Are equal or not.

Type declaration

    • (x: T, y: U): boolean
    • Parameters

      • x: T
      • y: U

      Returns boolean

ItemMessage

ItemMessage: string | function

An item message (provider).

Predicate

Predicate: function

A predicate / condition.

template

T Type of the item to check.

param

item to check.

returns

Item satisfies the condition or not.

Type declaration

    • (item: T): boolean
    • Parameters

      • item: T

      Returns boolean

Selector

Selector: function

A selector.

template

T Type of the source item.

template

U Type of the new item.

param

The source item.

returns

The new item.

Type declaration

    • (item: T): U
    • Parameters

      • item: T

      Returns U

Sequence

Sequence: ArrayLike<T> | Iterable<T> | Iterator<T> | IArguments

Possible sequence types.

template

T Type of the items.

ZipSelector

ZipSelector: function

A result selector for a 'zip' method / function.

param

The "left" value.

param

The "other" value.

param

The zero based index.

returns

The "zipped" result,

Type declaration

    • (x: T, y: U, index: number): TResult
    • Parameters

      • x: T
      • y: U
      • index: number

      Returns TResult

Variables

Const IS_EMPTY

IS_EMPTY: unique symbol = Symbol('IS_EMPTY')

Indicates that something is empty.

Const IS_ENUMERABLE

IS_ENUMERABLE: unique symbol = Symbol('IS_ENUMERABLE')

Indicates that something is an enumerable (sequence).

Const NOT_FOUND

NOT_FOUND: unique symbol = Symbol('NOT_FOUND')

Indicates if something was not found.

Functions

asEnumerable

  • Keeps sure that a value is a sequence.

    Type parameters

    • T

    Parameters

    • val: any

      The value to cast (if needed).

    Returns IEnumerable<T>

    The value as sequence. Can return (null) or (undefined), if 'val' is one of these values.

asFunc

  • asFunc<T>(val: any, throwException?: boolean): T | false
  • Returns a value as function.

    Type parameters

    • T: Function

    Parameters

    • val: any

      The function or a value that can be converted to a lambda expression string.

    • Default value throwException: boolean = true

      Throw an exception on parse errors or return (false).

    Returns T | false

    'val' as function or (false) on error, if 'throwException' is (false). Can be (null) or (undefined) if 'val' has a same value or is an empty string (representation).

build

buildInner

buildMany

  • Builds a flatten sequence of sequences.

    template

    T Type of the items.

    Type parameters

    • T

    Parameters

    Returns IEnumerable<T>

    The flatten list of items.

buildManyInner

create

  • Creates a new sequence from a list of items.

    template

    T Type of the items.

    Type parameters

    • T

    Parameters

    • Rest ...items: Array<T>

      The items for the sequence.

    Returns IEnumerable<T>

    The new sequence.

createGroupArrayForSequence

  • createGroupArrayForSequence<T, TKey>(seq: IEnumerable<T>, keySelector: Selector<T, TKey>): object[]

empty

  • Creates an empty sequence.

    template

    T The type of the sequence.

    Type parameters

    • T

    Returns IEnumerable<T>

    The new, empty sequence.

emptyIterator

  • emptyIterator(): IterableIterator<any>

from

  • Creates a new sequence.

    Type parameters

    • T

    Parameters

    • Optional seq: Sequence<T>

      The input data.

    Returns IEnumerable<T>

    The new sequence.

fromString

  • Creates a new sequence from the string representation of a value.

    Parameters

    • val: any

      The value.

    Returns IEnumerable<string>

    The new sequence.

getNextIteratorResultSafe

  • getNextIteratorResultSafe<T>(iterator: Iterator<T>, defaultValue?: any): IteratorResult<T>
  • Type parameters

    • T

    Parameters

    • iterator: Iterator<T>
    • Optional defaultValue: any

    Returns IteratorResult<T>

getOrDefaultArguments

  • getOrDefaultArguments<T, U>(predicateOrDefaultValue: Predicate<T> | T, defaultValue: U, paramCount: number): object
  • Type parameters

    • T

    • U

    Parameters

    • predicateOrDefaultValue: Predicate<T> | T
    • defaultValue: U
    • paramCount: number

    Returns object

    • defaultValue: any
    • predicate: function
        • (item: T): boolean
        • Parameters

          • item: T

          Returns boolean

invokeForValidNumber

  • invokeForValidNumber(x: any, action: function, handleAsInt?: boolean): any
  • Parameters

    • x: any
    • action: function
        • (n: number): any
        • Parameters

          • n: number

          Returns any

    • Default value handleAsInt: boolean = false

    Returns any

isEmpty

  • isEmpty(val: any): boolean
  • Checks if a value represents the IS_EMPTY symbol.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is IS_EMPTY symbol or not.

isEnumerable

  • isEnumerable<T>(val: any): boolean
  • Checks if a value represents an enumerable (sequence).

    Type parameters

    • T

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is enumerable (sequence) or not.

isNullOrEmpty

  • Checks if a sequence is (null) or empty.

    Type parameters

    • T

    Parameters

    Returns boolean

    Is (null) or empty.

isNullOrUndefined

  • isNullOrUndefined(val: any): boolean

isSequence

  • isSequence<T>(val: any): boolean
  • Checks if a value can be used as enumerable (sequence).

    Type parameters

    • T

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is sequence or not.

isUndefinedNullOrEmpty

  • isUndefinedNullOrEmpty<T>(seq: IEnumerable<T>): boolean
  • Checks if a sequence is (undefined) / (null) or empty.

    Type parameters

    • T

    Parameters

    Returns boolean

    Is (undefined), (null) or empty.

isUndefinedOrEmpty

  • Checks if a sequence is (undefined) or empty.

    Type parameters

    • T

    Parameters

    Returns boolean

    Is (undefined) or empty.

notFound

  • notFound(val: any): boolean
  • Checks if a value represents the NOT_FOUND symbol.

    Parameters

    • val: any

      The value to check.

    Returns boolean

    Is NOT_FOUND symbol or not.

popFrom

  • Creates a sequence from a stack by popping its elements.

    Type parameters

    • T

    Parameters

    Returns IEnumerable<T>

    The new sequence.

popFromInner

random

  • random(count?: number, valueProvider?: function): IEnumerable<number>
  • Returns a sequence of random numbers.

    Parameters

    • Optional count: number
    • Optional valueProvider: function
        • (randomValue: number, index: number): number
        • Parameters

          • randomValue: number
          • index: number

          Returns number

    Returns IEnumerable<number>

    The sequence of random numbers.

range

  • range(start: number, count?: number): IEnumerable<number>
  • Creates a range of numbers.

    Parameters

    • start: number

      The start value.

    • Optional count: number

    Returns IEnumerable<number>

    The new sequence.

rangeInner

  • rangeInner(start: number, count: number): IterableIterator<number>
  • Parameters

    • start: number
    • count: number

    Returns IterableIterator<number>

repeat

  • Creates a range of numbers.

    Type parameters

    • T

    Parameters

    • item: T

      The item to repeat.

    • Optional count: number

    Returns IEnumerable<T>

    The new sequence.

repeatInner

  • repeatInner<T>(item: T, count: number): IterableIterator<T>
  • Type parameters

    • T

    Parameters

    • item: T
    • count: number

    Returns IterableIterator<T>

shiftFrom

  • Creates a sequence from a stack by shifting its elements.

    Type parameters

    • T

    Parameters

    Returns IEnumerable<T>

    The new sequence.

shiftFromInner

sort

  • Returns a sorted sequence.

    template

    T Type of the items.

    template

    U Type of the keys.

    Type parameters

    • T

    • U

    Parameters

    Returns IOrderedEnumerable<T>

    The sorted sequence.

sortDesc

  • Returns a sorted sequence (descending).

    template

    T Type of the items.

    template

    U Type of the keys.

    Type parameters

    • T

    • U

    Parameters

    Returns IOrderedEnumerable<T>

    The sorted sequence.

toComparerSafe

toEqualityComparerSafe

toItemMessageSafe

  • toItemMessageSafe<T>(msgOrProvider: ItemMessage<T>): function
  • Type parameters

    • T

    Parameters

    Returns function

      • (item: T, index: number): string
      • Parameters

        • item: T
        • index: number

        Returns string

toPredicateSafe

  • toPredicateSafe<T>(predicate: Predicate<T> | boolean, defaultValue?: boolean): Predicate<T>

toStringSafe

  • toStringSafe(val: any): string

Generated using TypeDoc