(chunks: string[], limit: number)
| 5 | export const toArray = (arr: ArrayJoinInput<string>) => Array.isArray(arr) ? arr : [arr]; |
| 6 | |
| 7 | export const joinWithLineLimit = (chunks: string[], limit: number) => { |
| 8 | let arr: string[] = []; |
| 9 | let currentLine = chunks[0]; |
| 10 | for (let i = 1; i < chunks.length; i++) { |
| 11 | const chunk = chunks[i]; |
| 12 | if (currentLine.length + chunk.length <= limit) { |
| 13 | currentLine = currentLine.concat(" ", chunk); |
| 14 | } else { |
| 15 | arr.push(currentLine); |
| 16 | currentLine = chunk; |
| 17 | } |
| 18 | } |
| 19 | if (currentLine) { |
| 20 | arr.push(currentLine); |
| 21 | } |
| 22 | return arr; |
| 23 | }; |
| 24 | |
| 25 | export function arrJoiner(arr: ArrayJoinInput) { |
| 26 | const ret: string[] = []; |
nothing calls this directly
no outgoing calls
no test coverage detected