Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ArrayConstructor

Extends the built-in javascript Array object's static API.

The Format.Config.addUtilsToGlobals method must be called in order to access the definitions.

Hierarchy

  • ArrayConstructor

Index

Methods

Methods

compact

  • compact<T>(array: T[]): T[]
  • Removes "holes" (undefined elements) from the array making it compact/dense.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of elements in the array.

    Parameters

    • array: T[]

      An array instance.

    Returns T[]

    The same array instance without undefined elements.

takeWhile

  • takeWhile<T>(array: T[], predicate: function): T[]
  • Returns elements from a sequence as long as the specified condition is true.

    Must call Format.Config.addUtilsToGlobals to be defined.

    Type parameters

    • T

      The type of elements in the array.

    Parameters

    • array: T[]

      An array instance.

    • predicate: function

      A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

        • (item: T, index?: number): boolean
        • Parameters

          • item: T

            A source element that is tested for a condition.

          • Optional index: number

            The index of the source element.

          Returns boolean

    Returns T[]

    A new array instance containing only items for which the predicate function returned true.

Generated using TypeDoc