UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

2 lines 521 B
function e(e,n,r){return typeof e==`string`?t(e,n,r):r=>t(r,e,n)}function t(e,t,{omission:n=`...`,separator:r}={}){if(e.length<=t)return e;if(t<=0)return``;if(t<n.length)return n.slice(0,t);let i=t-n.length;if(typeof r==`string`){let t=e.lastIndexOf(r,i);t!==-1&&(i=t)}else if(r!==void 0){let t=r.flags.includes(`g`)?r:new RegExp(r.source,`${r.flags}g`),n;for(let{index:r}of e.matchAll(t)){if(r>i)break;n=r}n!==void 0&&(i=n)}return`${e.slice(0,i)}${n}`}export{e as truncate}; //# sourceMappingURL=truncate-C5kmIm4y.js.map