@whisklabs/grpc
Version:
gRPC generator and http library for typescript
48 lines • 1.47 kB
JavaScript
import { isPresent, isText } from '@whisklabs/typeguards';
import { cut } from './utils';
var comment = '';
var lastComment = {};
export function writeComment(com) {
var _a;
var co = ((_a = com.comment) !== null && _a !== void 0 ? _a : '') + comment;
if (isText(co)) {
com.comment = co;
}
comment = '';
lastComment = com;
}
export function setComment(com) {
lastComment = com;
}
export function cleanComment() {
comment = '';
}
export function next(tokens) {
while (tokens.length > 0) {
switch (tokens[0]) {
case '//': {
var comments = cut(tokens, 2);
comment = (comment !== '' ? "".concat(comment, "\n") : comment) + comments[1];
break;
}
case '/*': {
var commentsMulti = cut(tokens, 3);
comment = (comment !== '' ? "".concat(comment, "\n") : comment) + commentsMulti[1];
break;
}
case '!//': {
var commentInline = cut(tokens, 2);
comment = (comment !== '' ? "".concat(comment, "\n") : comment) + commentInline[1];
if (isPresent(lastComment)) {
lastComment.comment = comment;
comment = '';
}
break;
}
default:
return tokens[0];
}
}
return tokens[0];
}
//# sourceMappingURL=comment.js.map