UNPKG

@remotex-labs/xmap

Version:

A library with a sourcemap parser and TypeScript code formatter for the CLI

34 lines (33 loc) 948 B
// src/components/formatter.component.ts function l(a, r = {}) { let f = a.split(` `), n = r.padding ?? 10, i = r.startLine ?? 0; return f.map((c, o) => { let t = o + i + 1, e = `${`${t} | `.padStart(n)}${c}`; return r.action && t === r.action.triggerLine ? r.action.callback(e, n, t) : e; }).join(` `); } function u(a, r) { let { code: f, line: n, column: i, startLine: c } = a; if (n < c || i < 1) throw new Error("Invalid line or column number."); return l(f, { startLine: c, action: { triggerLine: n, callback: (o, t, s) => { let e = "^", p = t - 1, m = ">"; r && (e = r.color(e), p += e.length - 1, m = r.color(">")); let d = " | ".padStart(t) + " ".repeat(i - 1) + `${e}`; return o = `${m} ${s} |`.padStart(p) + o.split("|")[1], o + ` ${d}`; } } }); } export { l as formatCode, u as formatErrorCode }; //# sourceMappingURL=formatter.component.js.map