UNPKG

@clickup/rest-client

Version:

A syntax sugar tool around Node fetch() API, tailored to work with TypeScript and response validators

17 lines (13 loc) 454 B
const ELLIPSIS = "…"; /** * The fastest possible version of truncation. Lodash'es truncate() messes up * with unicode a lot, so for e.g. logging purposes, it's super-slow. */ export default function ellipsis(string: any, length: number) { string = ("" + string).trimEnd(); length = Math.max(length, ELLIPSIS.length); if (string.length <= length) { return string; } return string.substring(0, length - ELLIPSIS.length) + ELLIPSIS; }