MCPcopy
hub / github.com/smapiot/piral / readValidatorDescription

Function readValidatorDescription

tools/generate-command-docs.js:64–88  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

62}
63
64function readValidatorDescription(content) {
65 const head = 'export default ';
66 const lines = content.split('\n');
67
68 for (let i = 0; i < lines.length; i++) {
69 if (lines[i].startsWith(head)) {
70 const [start] = lines
71 .map((m, j) => ({
72 index: j,
73 found: j < i && m.startsWith('/**'),
74 }))
75 .filter((m) => m.found)
76 .map((m) => m.index)
77 .reverse();
78 const end = i - 1;
79 return lines
80 .filter((_, j) => j > start && j < end)
81 .map((m) => m.substr(2))
82 .join('')
83 .trim();
84 }
85 }
86
87 return '';
88}
89
90function readValidators() {
91 const baseDir = resolve(__dirname, validationFolder);

Callers 1

readValidatorsFunction · 0.85

Calls 2

mapMethod · 0.80
filterMethod · 0.65

Tested by

no test coverage detected