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

Function joinTokens

packages/codehike/src/code/highlight.ts:107–121  ·  view source on GitHub ↗
(tokens: Tokens)

Source from the content-addressed store, hash-verified

105}
106
107function joinTokens(tokens: Tokens): AnyToken[] {
108 return tokens.map((tokenOrGroup) => {
109 if ("tokens" in tokenOrGroup) {
110 throw new Error("Shouldnt be groups")
111 } else {
112 const t = [tokenOrGroup.content] as Token
113 const { color, ...rest } = tokenOrGroup.style || {}
114 t.push(color)
115 if (Object.keys(rest).length) {
116 t.push(rest)
117 }
118 return t
119 }
120 })
121}
122
123function splitWhitespace(tokens: AnyToken[]) {
124 const ejected: AnyToken[] = []

Callers 1

joinLinesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…