Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface IFilterLimitTo

Hierarchy

  • IFilterLimitTo

Callable

  • __call<T>(input: T[], limit: string | number, begin?: string | number): T[]
  • __call(input: string | number, limit: string | number, begin?: string | number): string
  • Creates a new array containing only a specified number of elements. The elements are taken from either the beginning or the end of the source array, string or number, as specified by the value and sign (positive or negative) of limit.

    Type parameters

    • T

    Parameters

    • input: T[]

      Source array to be limited.

    • limit: string | number

      The length of the returned array. If the limit number is positive, limit number of items from the beginning of the source array/string are copied. If the number is negative, limit number of items from the end of the source array are copied. The limit will be trimmed if it exceeds array.length. If limit is undefined, the input will be returned unchanged.

    • Optional begin: string | number

      Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0.

    Returns T[]

    A new sub-array of length limit or less if input array had less than limit elements.

  • Creates a new string containing only a specified number of elements. The elements are taken from either the beginning or the end of the source string or number, as specified by the value and sign (positive or negative) of limit. If a number is used as input, it is converted to a string.

    Parameters

    • input: string | number

      Source string or number to be limited.

    • limit: string | number

      The length of the returned string. If the limit number is positive, limit number of items from the beginning of the source string are copied. If the number is negative, limit number of items from the end of the source string are copied. The limit will be trimmed if it exceeds input.length. If limit is undefined, the input will be returned unchanged.

    • Optional begin: string | number

      Index at which to begin limitation. As a negative index, begin indicates an offset from the end of input. Defaults to 0.

    Returns string

    A new substring of length limit or less if input had less than limit elements.

Generated using TypeDoc