MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / joinWithLineLimit

Function joinWithLineLimit

src/lib/text.ts:7–23  ·  view source on GitHub ↗
(chunks: string[], limit: number)

Source from the content-addressed store, hash-verified

5export const toArray = (arr: ArrayJoinInput<string>) => Array.isArray(arr) ? arr : [arr];
6
7export 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
25export function arrJoiner(arr: ArrayJoinInput) {
26 const ret: string[] = [];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected