UNPKG

@autobe/agent

Version:

AI backend server code generator

43 lines 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StringUtil = void 0; var StringUtil; (function (StringUtil) { function trim(strings, ...values) { var _a; let result = strings[0]; for (let i = 0; i < values.length; i++) { result += String(values[i]) + strings[i + 1]; } const lines = result.split("\n"); while (lines.length > 0 && lines[0].trim() === "") { lines.shift(); } while (lines.length > 0 && lines[lines.length - 1].trim() === "") { lines.pop(); } if (lines.length === 0) return ""; const firstNonEmptyLine = lines.find((line) => line.trim() !== ""); if (!firstNonEmptyLine) return ""; const leadingWhitespace = ((_a = firstNonEmptyLine.match(/^[ \t]*/)) === null || _a === void 0 ? void 0 : _a[0]) || ""; const indentLength = leadingWhitespace.length; const trimmedLines = lines.map((line) => { if (line.trim() === "") return ""; return line.slice(indentLength); }); return trimmedLines.join("\n"); } StringUtil.trim = trim; function singleLine(strings, ...values) { let result = strings[0]; for (let i = 0; i < values.length; i++) { result += String(values[i]) + strings[i + 1]; } return result.replace(/\n/g, " ").replace(/\s+/g, " ").trim(); } StringUtil.singleLine = singleLine; })(StringUtil || (exports.StringUtil = StringUtil = {})); //# sourceMappingURL=StringUtil.js.map