UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 859 B
const graphemeSegmenter=new Intl.Segmenter(void 0,{granularity:`grapheme`});function graphemes(e){return Array.from(graphemeSegmenter.segment(e),({index:e,segment:t})=>({text:t,start:e,end:e+t.length}))}function previousGraphemeBoundary(e,t){let n=Math.max(0,Math.min(t,e.length));return n===0?0:graphemeSegmenter.segment(e).containing(n-1)?.index??0}function nextGraphemeBoundary(e,t){let n=Math.max(0,Math.min(t,e.length));if(n===e.length)return n;let r=graphemeSegmenter.segment(e).containing(n);return r===void 0?e.length:r.index+r.segment.length}function graphemeBoundaryAtOrAfter(e,t){let n=Math.max(0,Math.min(t,e.length));if(n===0||n===e.length)return n;let r=graphemeSegmenter.segment(e).containing(n);return r===void 0||r.index===n?n:r.index+r.segment.length}export{graphemeBoundaryAtOrAfter,graphemes,nextGraphemeBoundary,previousGraphemeBoundary};