Splits text into chunks with a maximum length, preferring to split at separators.
The text to split.
Maximum chunk length (positive safe integer).
Split points in order of preference (default: ['\n', ' ', '.']).
['\n', ' ', '.']
Array of text chunks.
If max_length is not a positive safe integer.
max_length
chunkText('hello world', 5); // ['hello', 'world']chunkText('hello world', 7); // ['hello', 'world']chunkText('abcdefghij', 5); // ['abcde', 'fghij']chunkText('a b c d e', 4); // ['a b', 'c d', 'e'] Copy
chunkText('hello world', 5); // ['hello', 'world']chunkText('hello world', 7); // ['hello', 'world']chunkText('abcdefghij', 5); // ['abcde', 'fghij']chunkText('a b c d e', 4); // ['a b', 'c d', 'e']
Splits text into chunks with a maximum length, preferring to split at separators.