UNPKG

qsu

Version:

qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.

1 lines 232 B
export function truncateExpect(t,e,n="."){if(!t)return"";if(t.length<=e)return t;const r=t.slice(-1)===n,l=t.split(n),c=l.length;let i="",u=0;for(let t=0;t<c&&u<e;t+=1)i+=`${l[t]}${t!==c-1||r?n:""}`,u+=l[t].length+n.length;return i}