UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

24 lines (22 loc) 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const code_block_writer_1 = require("code-block-writer"); const ManipulationSettings_1 = require("./../ManipulationSettings"); function getTextFromStringOrWriter(manipulationSettings, textOrWriterFunction) { if (typeof textOrWriterFunction === "string") return textOrWriterFunction; const writer = getCodeBlockWriter(manipulationSettings); textOrWriterFunction(writer); return writer.toString(); } exports.getTextFromStringOrWriter = getTextFromStringOrWriter; function getCodeBlockWriter(manipulationSettings) { const indentationText = manipulationSettings.getIndentationText(); return new code_block_writer_1.default({ newLine: manipulationSettings.getNewLineKind(), indentNumberOfSpaces: indentationText === ManipulationSettings_1.IndentationText.Tab ? undefined : indentationText.length, useTabs: indentationText === ManipulationSettings_1.IndentationText.Tab }); } exports.getCodeBlockWriter = getCodeBlockWriter; //# sourceMappingURL=getCodeBlockWriter.js.map