1 import slice from 'slice-ansi';
2 import stringWidth from 'string-width';
5 * Creates an array of strings split into groups the length of size.
6 * This function works with strings that contain ASCII characters.
8 * wrapText is different from would-be "chunk" implementation
9 * in that whitespace characters that occur on a chunk size limit are trimmed.
11 * @param {string} subject
12 * @param {number} size
15 export default (subject, size) => {
18 subjectSlice = subject;
23 chunks.push(slice(subjectSlice, 0, size));
25 subjectSlice = slice(subjectSlice, size).trim();
26 } while (stringWidth(subjectSlice));