1 import slice from 'slice-ansi';
2 import stringWidth from 'string-width';
5 * @param {string} input
9 export default (input, size) => {
16 // https://regex101.com/r/gY5kZ1/1
17 const re = new RegExp('(^.{1,' + size + '}(\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\|/|_|\\.|,|;|-))');
22 chunk = subject.match(re);
27 subject = slice(subject, stringWidth(chunk));
31 chunk = slice(subject, 0, size);
32 subject = slice(subject, size);
36 } while (stringWidth(subject));