MCPcopy
hub / github.com/code-hike/codehike / joinLines

Function joinLines

packages/codehike/src/code/highlight.ts:91–105  ·  view source on GitHub ↗
(lines: Lines)

Source from the content-addressed store, hash-verified

89
90// group the Lines into one array
91function joinLines(lines: Lines): AnyToken[] {
92 const joinedTokens: AnyToken[] = []
93 lines.forEach((lineOrGroup, i) => {
94 if ("lines" in lineOrGroup) {
95 throw new Error("Shouldnt be groups")
96 } else {
97 const tokens = joinTokens(lineOrGroup.tokens)
98 joinedTokens.push(...tokens)
99 if (i < lines.length - 1) {
100 joinedTokens.push("\n")
101 }
102 }
103 })
104 return joinedTokens
105}
106
107function joinTokens(tokens: Tokens): AnyToken[] {
108 return tokens.map((tokenOrGroup) => {

Callers 1

highlightFunction · 0.85

Calls 1

joinTokensFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…