UNPKG

pig-dam-core

Version:

Library that should be included in every Pig DAM project we build

29 lines (28 loc) 841 B
"use strict"; /** * Date: 6/2/20 * Time: 10:51 PM * @license MIT (see project's LICENSE file) */ Object.defineProperty(exports, "__esModule", { value: true }); exports.indentText = void 0; /** * Indents lines with the message. We use it for indenting nested errors * @param text - text to indent * @param depth - number of multiples of `indent` * @param indent - the text to use for each `depth` * @param skip - how many lines to skip before we start indenting */ function indentText(text, depth, { indent = " ", skip = 0 } = {}) { if (depth === 0) { return text; } return text.split(/\n/) .map((line, index) => { return (index >= skip && line.trim().length > 0) ? `${indent.repeat(depth)}${line}` : line; }) .join("\n"); } exports.indentText = indentText;