1 |
- {"version":3,"file":"unfetch.umd.js","sources":["../src/index.mjs"],"sourcesContent":["export default function(url, options) {\n\toptions = options || {};\n\treturn new Promise( (resolve, reject) => {\n\t\tconst request = new XMLHttpRequest();\n\t\tconst keys = [];\n\t\tconst all = [];\n\t\tconst headers = {};\n\n\t\tconst response = () => ({\n\t\t\tok: (request.status/100|0) == 2,\t\t// 200-299\n\t\t\tstatusText: request.statusText,\n\t\t\tstatus: request.status,\n\t\t\turl: request.responseURL,\n\t\t\ttext: () => Promise.resolve(request.responseText),\n\t\t\tjson: () => Promise.resolve(request.responseText).then(JSON.parse),\n\t\t\tblob: () => Promise.resolve(new Blob([request.response])),\n\t\t\tclone: response,\n\t\t\theaders: {\n\t\t\t\tkeys: () => keys,\n\t\t\t\tentries: () => all,\n\t\t\t\tget: n => headers[n.toLowerCase()],\n\t\t\t\thas: n => n.toLowerCase() in headers\n\t\t\t}\n\t\t});\n\n\t\trequest.open(options.method || 'get', url, true);\n\n\t\trequest.onload = () => {\n\t\t\trequest.getAllResponseHeaders().replace(/^(.*?):[^\\S\\n]*([\\s\\S]*?)$/gm, (m, key, value) => {\n\t\t\t\tkeys.push(key = key.toLowerCase());\n\t\t\t\tall.push([key, value]);\n\t\t\t\theaders[key] = headers[key] ? `${headers[key]},${value}` : value;\n\t\t\t});\n\t\t\tresolve(response());\n\t\t};\n\n\t\trequest.onerror = reject;\n\n\t\trequest.withCredentials = options.credentials=='include';\n\n\t\tfor (const i in options.headers) {\n\t\t\trequest.setRequestHeader(i, options.headers[i]);\n\t\t}\n\n\t\trequest.send(options.body || null);\n\t});\n}\n"],"names":["url","options","Promise","resolve","reject","request","XMLHttpRequest","keys","all","headers","response","ok","status","statusText","responseURL","text","responseText","json","then","JSON","parse","blob","Blob","clone","entries","get","n","toLowerCase","has","const","i","open","method","onload","getAllResponseHeaders","replace","m","key","value","push","onerror","withCredentials","credentials","setRequestHeader","send","body"],"mappings":"6KAAe,SAASA,EAAKC,UAC5BA,EAAUA,GAAW,GACd,IAAIC,iBAAUC,EAASC,OACvBC,EAAU,IAAIC,eACdC,EAAO,GACPC,EAAM,GACNC,EAAU,GAEVC,oBACLC,GAA8B,IAAzBN,EAAQO,OAAO,IAAI,GACxBC,WAAYR,EAAQQ,WACpBD,OAAQP,EAAQO,OAChBZ,IAAKK,EAAQS,YACbC,uBAAYb,QAAQC,QAAQE,EAAQW,eACpCC,uBAAYf,QAAQC,QAAQE,EAAQW,cAAcE,KAAKC,KAAKC,QAC5DC,uBAAYnB,QAAQC,QAAQ,IAAImB,KAAK,CAACjB,EAAQK,aAC9Ca,MAAOb,EACPD,QAAS,CACRF,uBAAYA,GACZiB,0BAAehB,GACfiB,aAAKC,UAAKjB,EAAQiB,EAAEC,gBACpBC,aAAKF,UAAKA,EAAEC,gBAAiBlB,UAmB1BoB,IAAMC,KAfXzB,EAAQ0B,KAAK9B,EAAQ+B,QAAU,MAAOhC,GAAK,GAE3CK,EAAQ4B,kBACP5B,EAAQ6B,wBAAwBC,QAAQ,wCAAiCC,EAAGC,EAAKC,GAChF/B,EAAKgC,KAAKF,EAAMA,EAAIV,eACpBnB,EAAI+B,KAAK,CAACF,EAAKC,IACf7B,EAAQ4B,GAAO5B,EAAQ4B,GAAU5B,EAAQ4B,OAAQC,EAAUA,IAE5DnC,EAAQO,MAGTL,EAAQmC,QAAUpC,EAElBC,EAAQoC,gBAAuC,WAArBxC,EAAQyC,YAElBzC,EAAQQ,QACvBJ,EAAQsC,iBAAiBb,EAAG7B,EAAQQ,QAAQqB,IAG7CzB,EAAQuC,KAAK3C,EAAQ4C,MAAQ"}
|