UNPKG

@prostory/mountain

Version:

Yet another HTTP/2 server and client.

3 lines (2 loc) 569 B
import{constants as n}from"http2";import{ContentType as e}from"../../constants.js";const r=async(r,o)=>new Promise(((t,s)=>{var E;const c=null!==(E=o[n.HTTP2_HEADER_CONTENT_TYPE])&&void 0!==E?E:"",a=[];c.includes(e.FORM_URLENCODED)||s(new Error(`Unexpected Content-Type - "${c}". Expected "${e.FORM_URLENCODED}"`)),r.setEncoding("utf8").on("error",s).on("data",a.push.bind(a)).on("end",(()=>t(a.join(""))))})).then((n=>Array.from(new URLSearchParams(n).entries()).reduce(((n,[e,r])=>({...n,[e]:r})),{})));export{r as urlencoded}; //# sourceMappingURL=urlencoded.js.map