UNPKG

@ea-lab/reactive-json

Version:

A REACT-based lib that transforms JSON (or YAML) into interactive HTML markup.

44 lines (43 loc) 1.06 kB
import { l as n } from "../../js-yaml-CFDLc3Ha.js"; const c = (t) => { try { return { success: !0, format: "json", data: JSON.parse(t) }; } catch (s) { const e = /at position (\d+)/.exec(s.message), o = e ? Number(e[1]) : null; return { error: s, success: !1, format: "json", position: o }; } }, r = (t) => { var s, e; try { return { success: !0, format: "yaml", data: n(t) }; } catch (o) { const a = ((e = (s = o == null ? void 0 : o.source) == null ? void 0 : s.range) == null ? void 0 : e.start) ?? (o == null ? void 0 : o.linePos) ?? null; return { error: o, success: !1, format: "yaml", position: a }; } }, l = (t) => { if (typeof t != "object") { const s = c(t); if (s.success || s.position !== null) return s; const e = r(t); return e.success || e.position !== null ? e : t.startsWith("{") || t.startsWith("[") ? s : e; } return { success: !0, format: "JS native object", data: t }; }; export { l as parseRjBuild };