Variable ArrayHelpersConst

ArrayHelpers: {
    cleanStringArray: ((array?) => undefined | string[]);
    createSuite: ((length, offset?, step?) => number[]);
    first: (<T>(array) => undefined | T);
    firstOptional: (<T>(array) => Optional<T>);
    last: (<T>(array) => undefined | T);
    lastOptional: (<T>(array) => Optional<T>);
    matchAll: (<T>(array, predicate) => boolean);
    matchOneExactly: (<T>(array, predicate) => boolean);
    matchOneOrMore: (<T>(array, predicate) => boolean);
    same: (<T>(array1, array2, comparator?) => boolean);
    shuffle: (<T>(array) => T[]);
    uniq: (<T>(array) => T[]);
    uniqObjectsByProperty: (<T>(array, property, comparator?) => T[]);
} = ...

Type declaration

  • cleanStringArray: ((array?) => undefined | string[])

    Strips the given string array of any blank values (either null, undefined of empty string).

    Param: array

    The string array to be cleaned.

    Returns

    undefined if the given array was undefined, the cleaned up array otherwise.

      • (array?): undefined | string[]
      • Strips the given string array of any blank values (either null, undefined of empty string).

        Parameters

        • Optional array: (undefined | null | string)[]

          The string array to be cleaned.

        Returns undefined | string[]

        undefined if the given array was undefined, the cleaned up array otherwise.

  • createSuite: ((length, offset?, step?) => number[])

    Creates an array of the given length composed of a suite of numbers from offset to offset + (length * step).

    Param: length

    The length of the array to be created.

    Param: offset

    The starting offset of the suite to be created. 1 is set by default.

    Returns

    the suite array from offset to offset + (length * step).

      • (length, offset?, step?): number[]
      • Creates an array of the given length composed of a suite of numbers from offset to offset + (length * step).

        Parameters

        • length: number

          The length of the array to be created.

        • offset: number = 1

          The starting offset of the suite to be created. 1 is set by default.

        • step: number = 1

        Returns number[]

        the suite array from offset to offset + (length * step).

  • first: (<T>(array) => undefined | T)

    Extracts the first element from the given array.

    Param: array

    The array to extract the first element from.

    Returns

    the first element.

      • <T>(array): undefined | T
      • Extracts the first element from the given array.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to extract the first element from.

        Returns undefined | T

        the first element.

  • firstOptional: (<T>(array) => Optional<T>)

    Extracts the first element from the given array as an optional.

    Param: array

    The array to extract the first element from.

    Returns

    the first element as an optional.

      • <T>(array): Optional<T>
      • Extracts the first element from the given array as an optional.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to extract the first element from.

        Returns Optional<T>

        the first element as an optional.

  • last: (<T>(array) => undefined | T)

    Extracts the last element from the given array.

    Param: array

    The array to extract the last element from.

    Returns

    the last element.

      • <T>(array): undefined | T
      • Extracts the last element from the given array.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to extract the last element from.

        Returns undefined | T

        the last element.

  • lastOptional: (<T>(array) => Optional<T>)

    Extracts the last element from the given array as an optional.

    Param: array

    The array to extract the last element from.

    Returns

    the last element as an optional.

      • <T>(array): Optional<T>
      • Extracts the last element from the given array as an optional.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to extract the last element from.

        Returns Optional<T>

        the last element as an optional.

  • matchAll: (<T>(array, predicate) => boolean)

    Tests if all elements of the given array match the predicate.

    Param: array

    The array to test

    Param: predicate

    The predicate used to test each element of the given array

    Returns

    true if all of the elements match the given predicate, false otherwise.

      • <T>(array, predicate): boolean
      • Tests if all elements of the given array match the predicate.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to test

        • predicate: Predicate<T>

          The predicate used to test each element of the given array

        Returns boolean

        true if all of the elements match the given predicate, false otherwise.

  • matchOneExactly: (<T>(array, predicate) => boolean)

    Tests if exactly one element of the given array matches the predicate.

    Param: array

    The array to test

    Param: predicate

    The predicate used to test each element of the given array

    Returns

    true if one element only matches the given predicate, false otherwise.

      • <T>(array, predicate): boolean
      • Tests if exactly one element of the given array matches the predicate.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to test

        • predicate: Predicate<T>

          The predicate used to test each element of the given array

        Returns boolean

        true if one element only matches the given predicate, false otherwise.

  • matchOneOrMore: (<T>(array, predicate) => boolean)

    Tests if at least one element of the given array matches the predicate.

    Param: array

    The array to test

    Param: predicate

    The predicate used to test each element of the given array

    Returns

    true if at leat one element matches the given predicate, false otherwise.

      • <T>(array, predicate): boolean
      • Tests if at least one element of the given array matches the predicate.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to test

        • predicate: Predicate<T>

          The predicate used to test each element of the given array

        Returns boolean

        true if at leat one element matches the given predicate, false otherwise.

  • same: (<T>(array1, array2, comparator?) => boolean)

    Tests whether the given arrays are exactly the same in length and content. If no predicate is given to compare the elements of the arrays, === will be used.

    Param: array1

    The first array to test

    Param: array2

    The second array to test

    Param: comparator

    The predicate used to compare each element of the given arrays.

    Returns

    true if both arrays are equal, false otherwise.

      • <T>(array1, array2, comparator?): boolean
      • Tests whether the given arrays are exactly the same in length and content. If no predicate is given to compare the elements of the arrays, === will be used.

        Type Parameters

        • T

        Parameters

        • array1: T[]

          The first array to test

        • array2: T[]

          The second array to test

        • Optional comparator: Function2<T, T, boolean>

          The predicate used to compare each element of the given arrays.

        Returns boolean

        true if both arrays are equal, false otherwise.

  • shuffle: (<T>(array) => T[])

    Shuffles the elements of the given array to a random order.

    Param: array

    The array to shuffle.

    Returns

    An array with every elements of the given array but in a random order.

      • <T>(array): T[]
      • Shuffles the elements of the given array to a random order.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array to shuffle.

        Returns T[]

        An array with every elements of the given array but in a random order.

  • uniq: (<T>(array) => T[])

    Strips the given array of duplicate values.

    Param: array

    The array with potential duplicates.

    Returns

    An array where of elements are uniq.

      • <T>(array): T[]
      • Strips the given array of duplicate values.

        Type Parameters

        • T

        Parameters

        • array: T[]

          The array with potential duplicates.

        Returns T[]

        An array where of elements are uniq.

  • uniqObjectsByProperty: (<T>(array, property, comparator?) => T[])

    Strips the given array of duplicate property values.

    Param: array

    The array with potential duplicates.

    Param: property

    The property to extract for the comparaison.

    Param: comparator

    The predicate used to compare each element of the given arrays.

    Returns

    An array where of elements are uniq.

      • <T>(array, property, comparator?): T[]
      • Strips the given array of duplicate property values.

        Type Parameters

        • T extends {
              [id: string]: any;
          }

        Parameters

        • array: T[]

          The array with potential duplicates.

        • property: string

          The property to extract for the comparaison.

        • Optional comparator: Function2<T, T, boolean>

          The predicate used to compare each element of the given arrays.

        Returns T[]

        An array where of elements are uniq.

Generated using TypeDoc