MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / parse

Function parse

packages/ast/parse/parse.js:37–74  ·  view source on GitHub ↗
(input, matchers)

Source from the content-addressed store, hash-verified

35}
36
37function parse(input, matchers) {
38 const children = [];
39 const length = input.length;
40
41 let index = 0;
42 let buffer = '';
43
44 function flush() {
45 if (buffer) {
46 children.push({
47 type: 'text',
48 value: buffer,
49 source: buffer,
50 });
51 buffer = '';
52 }
53 }
54
55 while (index < length) {
56 const result = match(input, index, matchers);
57
58 if (result) {
59 flush();
60
61 const [node, position] = result;
62 children.push(node);
63 index = position;
64 continue;
65 }
66
67 buffer += input[index];
68 index++;
69 }
70
71 flush();
72
73 return children;
74}
75
76module.exports = function (input, matchers) {
77 try {

Callers 4

getUserMentionsFunction · 0.90
getTitleFunction · 0.90
MessageFunction · 0.90
parse.jsFile · 0.70

Calls 2

matchFunction · 0.85
flushFunction · 0.70

Tested by

no test coverage detected