• truncates the passed in string if its length exceeds the length specified by finalLength and adds an ellipsis at the point of truncation

    ex:

    const original = 'the quick brown fox jumped over the lazy dogs';
    ellide(original, 10); // 'the qui...'
    ellide(original, 10, 'beginning'); // '...zy dogs'
    ellide(original, 10, 'middle'); // 'the...dogs'
    ellide(original, 10, 'end', '_'); // 'the quick_'

    Parameters

    • original: string

      the original string to be ellided if over the specified finalLength

    • finalLength: number

      the maximum length the output string can be (including ellipsis)

    • ellipsisLocation: EllipsisLocation = 'end'

      a value of beginning, middle, or end indicating where the ellipsis will be added and what part of the input string will be truncated

    • ellipsis: string = '...'

      the value to use as the ellipsis

    Returns string

    if the original string is over the length specified by finalLength then a truncated string will be returned with the ellipsis character(s) at the location of the truncation as specified by the ellipsisLocation

    Default

    end
    

    Default

    '...'
    

Generated using TypeDoc