UNPKG

my-utils-engine

Version:

Funções utilitárias para projetos em Angola (BI, telefone, currency, etc.) Comentários: os comentários no código estão em português. Nomes de funções em inglês.

18 lines (17 loc) 611 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.truncateText = void 0; /** * Trunca uma string para um comprimento especificado e anexa um sufixo. * @param text A string a ser truncada. * @param maxLength O comprimento máximo da string. * @param suffix O sufixo a ser anexado se a string for truncada (padrão é '...'). * @returns A string truncada. */ const truncateText = (text, maxLength, suffix = '...') => { if (text.length <= maxLength) { return text; } return text.substring(0, maxLength) + suffix; }; exports.truncateText = truncateText;