MCPcopy Create free account
hub / github.com/editablejs/editable / getCharRange

Function getCharRange

packages/editor/src/utils/text.ts:51–59  ·  view source on GitHub ↗
(text: string, offset: number)

Source from the content-addressed store, hash-verified

49 * @returns [start, end]
50 */
51export const getCharRange = (text: string, offset: number) => {
52 let i = 0
53 for (; i <= offset; ) {
54 const end = i + getCharOffsetForward(text, i)
55 if (end > offset) return [i, end]
56 i = end
57 }
58 return [i, i + Math.min(text.length, 1)]
59}
60
61const isSpace = (char: string) => /\s/.test(char)
62// http://www.unicode.org/charts/

Callers 1

getTextOffsetFunction · 0.85

Calls 1

getCharOffsetForwardFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…