How to use the @ts-morph/common.StringUtils.startsWithNewLine function in @ts-morph/common

To help you get started, we’ve selected a few @ts-morph/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dsherret / ts-morph / packages / ts-morph / src / compiler / ast / utils / CommentNodeParser.ts View on Github external
const commentKind = getCommentKind();
                if (commentKind != null) {
                    const comment = parseForComment(commentKind);
                    if (comment.kind === SyntaxKind.SingleLineCommentTrivia)
                        return;
                    else
                        lineEnd = StringUtils.getLineEndFromPos(sourceFileText, pos);
                }
                // skip any trailing comments too
                else if (!StringUtils.isWhitespace(sourceFileText[pos]) && sourceFileText[pos] !== ",")
                    return;
                else
                    pos++;
            }

            while (StringUtils.startsWithNewLine(sourceFileText[pos]))
                pos++;
        }
github dsherret / ts-morph / packages / ts-morph / src / structurePrinters / doc / JSDocTagStructurePrinter.ts View on Github external
function getText(tagPrinter: JSDocTagStructurePrinter) {
            if (typeof structure === "string")
                return structure;
            const tempWriter = tagPrinter.getNewWriter(writer);
            if (typeof structure === "function")
                structure(tempWriter);
            else {
                if (structure.text)
                    printTextFromStringOrWriter(tempWriter, structure.text);
                const currentText = tempWriter.toString();
                tempWriter.unsafeInsert(0, `@${structure.tagName}` + (currentText.length > 0 && !StringUtils.startsWithNewLine(currentText) ? " " : ""));
            }

            return tempWriter.toString();
        }
    }
github dsherret / ts-morph / packages / ts-morph / src / manipulation / manipulations / insertion.ts View on Github external
function prependSeparator() {
        if (!StringUtils.startsWithNewLine(newText))
            newText = separator + newText;
    }