MCPcopy Create free account
hub / github.com/pomber/code-surfer / flattenTokens

Function flattenTokens

packs/step-parser/src/tokenizer.ts:96–107  ·  view source on GitHub ↗
(tokens: NestedToken[])

Source from the content-addressed store, hash-verified

94// and flatten it so content is always a string
95// and type the type of the leaf
96function flattenTokens(tokens: NestedToken[]) {
97 const flatList: FlatToken[] = [];
98 tokens.forEach(token => {
99 const { type, content } = token;
100 if (Array.isArray(content)) {
101 flatList.push(...flattenTokens(content));
102 } else {
103 flatList.push({ type, content });
104 }
105 });
106 return flatList;
107}
108
109export class MissingGrammarError extends Error {
110 lang: string;

Callers 1

tokenizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected