UNPKG

jest-allure2-reporter

Version:
20 lines 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.autoIndent = autoIndent; function autoIndent(text) { const [first, ...rest] = text.split('\n'); const indent = detectIndent(rest); if (indent > 0) { return [first, ...rest.map((line) => line.slice(indent))].join('\n'); } return text; } function detectIndent(lines) { const result = lines.reduce((min, line) => { const trimmed = line.trimStart(); const indent = trimmed === '' ? min : line.length - trimmed.length; return Math.min(indent, min); }, Number.POSITIVE_INFINITY); return Number.isFinite(result) ? result : 0; } //# sourceMappingURL=autoIndent.js.map