You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
446 B
TypeScript
11 lines
446 B
TypeScript
import { chunkTextByBreakResolver } from "../shared/text-chunking.js";
|
|
|
|
/** Chunk outbound text while preferring newline boundaries over spaces. */
|
|
export function chunkTextForOutbound(text: string, limit: number): string[] {
|
|
return chunkTextByBreakResolver(text, limit, (window) => {
|
|
const lastNewline = window.lastIndexOf("\n");
|
|
const lastSpace = window.lastIndexOf(" ");
|
|
return lastNewline > 0 ? lastNewline : lastSpace;
|
|
});
|
|
}
|