@prostory/mountain
Version:
Yet another HTTP/2 server and client.
3 lines (2 loc) • 457 B
JavaScript
import{constants as n}from"http2";import{ContentType as o}from"../../constants.js";const e=async(e,t)=>new Promise(((r,s)=>{var p;const c=null!==(p=t[n.HTTP2_HEADER_CONTENT_TYPE])&&void 0!==p?p:"",d=[];c.includes(o.JSON)||s(new Error(`Unexpected Content-Type - "${c}". Expected "${o.JSON}"`)),e.setEncoding("utf8").on("error",s).on("data",d.push.bind(d)).on("end",(()=>r(d.join(""))))})).then(JSON.parse);export{e as json};
//# sourceMappingURL=json.js.map