UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

14 lines (13 loc) 734 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("./../../utils"); // todo: remove this function? function getIndentedText(opts) { var textOrWriterFunction = opts.textOrWriterFunction, manipulationSettings = opts.manipulationSettings, indentationText = opts.indentationText; var newLineKind = manipulationSettings.getNewLineKindAsString(); var originalText = utils_1.getTextFromStringOrWriter(manipulationSettings, textOrWriterFunction); if (originalText.length > 0) return originalText.split(/\r?\n/).map(function (t) { return t.length > 0 ? indentationText + t : t; }).join(newLineKind); return originalText; } exports.getIndentedText = getIndentedText;