UNPKG

@whisklabs/grpc

Version:

gRPC generator and http library for typescript

55 lines 1.81 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.next = exports.cleanComment = exports.setComment = exports.writeComment = void 0; var typeguards_1 = require("@whisklabs/typeguards"); var utils_1 = require("./utils"); var comment = ''; var lastComment = {}; function writeComment(com) { var _a; var co = ((_a = com.comment) !== null && _a !== void 0 ? _a : '') + comment; if ((0, typeguards_1.isText)(co)) { com.comment = co; } comment = ''; lastComment = com; } exports.writeComment = writeComment; function setComment(com) { lastComment = com; } exports.setComment = setComment; function cleanComment() { comment = ''; } exports.cleanComment = cleanComment; function next(tokens) { while (tokens.length > 0) { switch (tokens[0]) { case '//': { var comments = (0, utils_1.cut)(tokens, 2); comment = (comment !== '' ? "".concat(comment, "\n") : comment) + comments[1]; break; } case '/*': { var commentsMulti = (0, utils_1.cut)(tokens, 3); comment = (comment !== '' ? "".concat(comment, "\n") : comment) + commentsMulti[1]; break; } case '!//': { var commentInline = (0, utils_1.cut)(tokens, 2); comment = (comment !== '' ? "".concat(comment, "\n") : comment) + commentInline[1]; if ((0, typeguards_1.isPresent)(lastComment)) { lastComment.comment = comment; comment = ''; } break; } default: return tokens[0]; } } return tokens[0]; } exports.next = next; //# sourceMappingURL=comment.js.map