UNPKG

@mastra/core

Version:
11 lines • 717 B
/** * `sliceByTokens` from tokenx cuts on UTF-16 code-unit boundaries, so a cut can * land inside a surrogate pair (emoji, CJK ext B+, math alphanumerics) and leave * an unpaired surrogate. That is invalid UTF-16: it degrades to U+FFFD on a UTF-8 * round-trip and strict JSON parsers reject it. Always slice through this helper * so every truncation site gets the same repair. */ export declare function sliceByTokensSafe(text: string, start: number, end?: number): string; /** `text.slice(start, end)` by UTF-16 index, with the same repair for a cut inside a surrogate pair. */ export declare function sliceSafe(text: string, start?: number, end?: number): string; //# sourceMappingURL=slice-by-tokens.d.ts.map