UNPKG

piecemeal

Version:

Effortless incrementally deliver your data

1 lines 524 B
function t(t,n){let e=[""];for(let t in n)e.push(`${t}: ${n[t]}`);return e.push("",String(t),""),e.join("\r\n")}function n(t){return"headers"in t&&"data"in t}async function e(e,a,i,r){await i(`--${a}`);for await(let o of e){if(r&&r.aborted)break;let e,f=o,s=typeof o;null===o?f="":"object"===s?n(o)?(e=o.headers,f=o.data):(e={"content-type":"application/json;charset=utf-8"},f=JSON.stringify(o)):"string"!==s&&(f=String(o)),e=e||{"content-type":"text/plain"},await i(t(f,e)+`--${a}`)}await i("--\r\n")}export{e as generate};