UNPKG

@scalar/api-client

Version:

the open source API testing client

50 lines (49 loc) 2.24 kB
const c = (r, n) => typeof r == "string" ? r : n.includes("json") || typeof r == "object" && r !== null && !Array.isArray(r) ? JSON.stringify(r) : String(r), j = (r, n) => { if (Array.isArray(r)) return r.join(","); if (typeof r == "object" && r !== null) { const t = Object.entries(r); return n ? t.map(([e, i]) => `${e}=${i}`).join(",") : t.map(([e, i]) => `${e},${i}`).join(","); } return r; }, p = (r, n) => Array.isArray(r) && n ? r.map((t) => ({ key: "", value: t })) : Array.isArray(r) ? r.join(",") : typeof r == "object" && r !== null && n ? Object.entries(r).map(([t, e]) => ({ key: t, value: e })) : typeof r == "object" && r !== null ? Object.entries(r).map(([t, e]) => `${t},${e}`).join(",") : r, A = (r, n) => { if (Array.isArray(r) && n) return r.map((t) => ({ key: "", value: t })); if (Array.isArray(r)) return r.map((t) => t === null ? "null" : String(t)).join(","); if (typeof r == "object" && r !== null && n) return Object.entries(r).map(([t, e]) => ({ key: t, value: e })); if (typeof r == "object" && r !== null) { const t = (e) => { const i = []; for (const [y, o] of Object.entries(e)) typeof o == "object" && o !== null && !Array.isArray(o) ? i.push(y, ...t(o)) : i.push(y, o === null ? "null" : String(o)); return i; }; return t(r).join(","); } return r; }, b = (r) => Array.isArray(r) ? r.join(" ") : typeof r == "object" && r !== null ? Object.entries(r).map(([n, t]) => `${n} ${t}`).join(" ") : String(r), l = (r) => Array.isArray(r) ? r.join("|") : typeof r == "object" && r !== null ? Object.entries(r).flat().join("|") : String(r), S = (r, n) => { const t = [], e = (i, y) => { for (const [o, s] of Object.entries(i)) { const f = `${y}[${o}]`; typeof s == "object" && s !== null && !Array.isArray(s) ? e(s, f) : t.push({ key: f, value: String(s) }); } }; return typeof n == "object" && n !== null && !Array.isArray(n) && e(n, r), t; }; export { c as serializeContentValue, S as serializeDeepObjectStyle, p as serializeFormStyle, A as serializeFormStyleForCookies, l as serializePipeDelimitedStyle, j as serializeSimpleStyle, b as serializeSpaceDelimitedStyle };