The input string to split.
Predicate to determine whether a character is a delimiter.
Array of tuples: [delimiterRun, token].
// Split on spaces and punctuation
const isDelim = (ch) => ch === ' ' || ch === '-' || ch === '!';
splitRuns('hello world', isDelim);
[
["", "hello"],
[" ", "world"],
]
splitRuns('hello world!', isDelim);
[
["", "hello"],
[" ", "world"],
["!", ""]
]
splitRuns('- hello world!', isDelim);
[
["- ", "hello"],
[" ", "world"],
["!", ""]
]
Splits a string into pairs of
[delimiterRun, token], preserving contiguous delimiter runs.