Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function adjustMultilineComment(value: string, base: string = '', specialBase: any) {
var array, i, len, line, j, spaces, previousBase, sn;
array = value.split(/\r\n|[\r\n]/);
spaces = Number.MAX_VALUE;
// first line doesn't have indentation
for (i = 1, len = array.length; i < len; ++i) {
line = array[i];
j = 0;
while (j < line.length && esutils.code.isWhiteSpace(line.charCodeAt(j))) {
++j;
}
if (spaces > j) {
spaces = j;
}
}
if (typeof specialBase !== 'undefined') {
// pattern like
// {
// var t = 20; /*
// * this is comment
// */
// }
previousBase = base;
if (array[1][spaces] === '*') {
if (comment.type !== 'Line') {
this.finishCurrent();
this.result.push(new CommentBlock(comment));
return this;
}
if (!this.current) {
this.current = new CommentBlock(comment);
return this;
}
// Both comment and this.current are single line comments.
for (i = this.current.comments[this.current.comments.length - 1].range[1], iz = comment.range[0]; i < iz; ++i) {
code = source.charCodeAt(i);
if (!esutils.code.isLineTerminator(code) && !esutils.code.isWhiteSpace(code)) {
// Not contiguous.
this.finishCurrent();
this.current = new CommentBlock(comment);
return this;
}
}
this.current.append(comment);
return this;
};
this.put(";");
}
}
if (this.lastNumber !== null && tokenStr.length == 1) {
if (tokenStr === ".") {
this.result += numberDot(this.lastNumber);
this.lastNumber = null;
this.lastChar = ".";
return;
}
}
this.lastNumber = null;
var rightChar = tokenStr.charAt(0);
var lastChar = this.lastChar;
this.lastChar = tokenStr.charAt(tokenStr.length - 1);
if (lastChar && ((lastChar == "+" || lastChar == "-") && lastChar == rightChar || _esutils.code.isIdentifierPartES6(lastChar.charCodeAt(0)) && _esutils.code.isIdentifierPartES6(rightChar.charCodeAt(0)) || lastChar == "/" && rightChar == "i")) {
this.result += " ";
}
this.result += tokenStr;
}
}]);
this.put(";");
}
}
if (this.lastNumber !== null && tokenStr.length == 1) {
if (tokenStr === ".") {
this.result += numberDot(this.lastNumber);
this.lastNumber = null;
this.lastChar = ".";
return;
}
}
this.lastNumber = null;
var rightChar = tokenStr.charAt(0);
var lastChar = this.lastChar;
this.lastChar = tokenStr.charAt(tokenStr.length - 1);
if (lastChar && ((lastChar == "+" || lastChar == "-") && lastChar == rightChar || _esutils.code.isIdentifierPartES6(lastChar.charCodeAt(0)) && _esutils.code.isIdentifierPartES6(rightChar.charCodeAt(0)) || lastChar == "/" && rightChar == "i")) {
this.result += " ";
}
this.result += tokenStr;
}
}]);