Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "source/System/Collections/Array/Utility"

Index

Functions

applyTo

  • applyTo<T>(target: IArray, fn: function): void
  • Is similar to Array.map() but instead of returning a new array, it updates the existing indexes. Can also be applied to a structure that indexes like an array, but may not be.

    Type parameters

    • T

    Parameters

    • target: IArray
    • fn: function
        • (a: T): T
        • Parameters

          • a: T

          Returns T

    Returns void

clear

  • clear(array: IArray, start?: number, stop?: number): void
  • Clears (sets to null) values of an array across a range of indexes.

    Parameters

    • array: IArray
    • Default value start: number = 0
    • Optional stop: number

    Returns void

contains

  • Checks to see if the provided array contains an item. If the array value is null, then false is returned.

    Type parameters

    • T

    Parameters

    Returns boolean

copy

  • copy<T>(source: IArray, sourceIndex?: number, length?: number): T[]
  • Type parameters

    • T

    Parameters

    • source: IArray
    • Default value sourceIndex: number = 0
    • Default value length: number = Infinity

    Returns T[]

copyTo

  • copyTo<T, TDestination>(source: IArray, destination: TDestination, sourceIndex?: number, destinationIndex?: number, length?: number): TDestination
  • Copies one array to another.

    Type parameters

    Parameters

    • source: IArray
    • destination: TDestination
    • Default value sourceIndex: number = 0
    • Default value destinationIndex: number = 0
    • Default value length: number = Infinity

      An optional limit to stop copying.

    Returns TDestination

    The destination array.

distinct

  • distinct(source: string[]): string[]
  • distinct(source: number[]): number[]
  • Returns a unique reduced set of values.

    Parameters

    • source: string[]

    Returns string[]

  • Parameters

    • source: number[]

    Returns number[]

findIndex

  • Returns the first index of which the provided predicate returns true. Returns -1 if always false.

    Type parameters

    • T

    Parameters

    Returns number

flatten

  • flatten(a: any[], recurseDepth?: number): any[]
  • Takes any arrays within an array and inserts the values contained within in place of that array. For every count higher than 0 in recurseDepth it will attempt an additional pass. Passing Infinity will flatten all arrays contained.

    Parameters

    • a: any[]
    • Default value recurseDepth: number = 0

    Returns any[]

forEach

  • Allows for using "false" to cause forEach to break. Can also be applied to a structure that indexes like an array, but may not be.

    Type parameters

    • T

    Parameters

    Returns void

indexOf

  • Checks to see where the provided array contains an item/value. If the array value is null, then -1 is returned.

    Type parameters

    • T

    Parameters

    Returns number

initialize

  • initialize<T>(length: number): T[]
  • Initializes an array depending on the requested capacity. The returned array will have a .length equal to the value provided.

    Type parameters

    • T

    Parameters

    • length: number

    Returns T[]

range

  • range(first: number, count: number, step?: number): number[]
  • Returns a range of numbers based upon the first value and the step value.

    Parameters

    • first: number
    • count: number
    • Default value step: number = 1

    Returns number[]

rangeUntil

  • rangeUntil(first: number, until: number, step?: number): number[]
  • Returns a range of numbers based upon the first value and the step value excluding any numbers at or beyond the until value.

    Parameters

    • first: number
    • until: number
    • Default value step: number = 1

    Returns number[]

register

  • Ensures a value exists within an array. If not found, adds to the end.

    Type parameters

    • T

    Parameters

    Returns boolean

remove

  • remove<T>(array: T[], value: T, max?: number, equalityComparer?: EqualityComparison<T>): number
  • Finds and removes a value from an array. Will remove all instances unless a maximum is specified.

    Type parameters

    • T

    Parameters

    • array: T[]
    • value: T
    • Optional max: number
    • Default value equalityComparer: EqualityComparison<T> = areEqual

    Returns number

    The number of times the value was found and removed.

removeIndex

  • removeIndex<T>(array: T[], index: number): boolean
  • Removes an entry at a specified index.

    Type parameters

    • T

    Parameters

    • array: T[]
    • index: number

    Returns boolean

    True if the value was able to be removed.

repeat

  • repeat<T>(element: T, count: number): T[]
  • Simply repeats a value the number of times specified.

    Type parameters

    • T

    Parameters

    • element: T
    • count: number

    Returns T[]

replace

  • replace<T>(array: IArray, old: T, newValue: T, max?: number): number
  • Finds and replaces a value from an array. Will replaces all instances unless a maximum is specified.

    Type parameters

    • T

    Parameters

    • array: IArray
    • old: T
    • newValue: T
    • Optional max: number

    Returns number

updateRange

  • updateRange<T>(array: IArray, value: T, start?: number, stop?: number): void
  • Replaces values of an array across a range of indexes.

    Type parameters

    • T

    Parameters

    • array: IArray
    • value: T
    • Default value start: number = 0
    • Optional stop: number

    Returns void

Generated using TypeDoc