first commit
This commit is contained in:
commit
12e4f17b62
4633 files changed
+817125
No files matched your search
@@ -0,0 +1,18 @@
|
||||
export function commentParser(text) {
|
||||
text = text.trim();
|
||||
|
||||
if (text.substr(0, 2) === '//') {
|
||||
return [
|
||||
'line',
|
||||
text.split(/\r?\n/).map(function (line) {
|
||||
return line.substr(2);
|
||||
}),
|
||||
];
|
||||
} else if (text.substr(0, 2) === '/*' && text.substr(-2) === '*/') {
|
||||
return ['block', text.substring(2, text.length - 2)];
|
||||
} else {
|
||||
throw new Error(
|
||||
'Could not parse comment file: the file must contain either just line comments (//) or a single block comment (/* ... */)',
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user