MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / flush

Function flush

packages/ast/parse/linen/listify/index.js:11–50  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9 let ordered = false;
10
11 function flush() {
12 if (type === 'list') {
13 const previous = tokens[tokens.length - 1];
14 if (
15 previous &&
16 previous.type === 'list' &&
17 previous.ordered === ordered
18 ) {
19 previous.source += `\n${prefix} ${value}`;
20 previous.children.push({
21 type: 'item',
22 source: value,
23 children: [{ type: 'text', source: value, value }],
24 });
25 } else {
26 tokens.push({
27 type: 'list',
28 source: `${prefix} ${value}`,
29 ordered,
30 children: [
31 {
32 type: 'item',
33 source: value,
34 children: [{ type: 'text', source: value, value }],
35 },
36 ],
37 });
38 }
39 } else if (type === 'text') {
40 if (value) {
41 const previous = tokens[tokens.length - 1];
42 if (previous && previous.type === 'text') {
43 previous.value += value;
44 } else {
45 tokens.push({ type, value });
46 }
47 }
48 }
49 value = '';
50 }
51
52 while (index < length) {
53 let current = input[index];

Callers 1

tokenizeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected