@onesy/utils
Version:
13 lines (12 loc) • 497 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const is_1 = __importDefault(require("./is"));
const truncate = (text, maxLength = 50, sufix = '...') => {
if (!(0, is_1.default)('string', text))
return text;
return text.length > maxLength ? text.slice(0, maxLength) + sufix : text;
};
exports.default = truncate;