gmxhr-fetch
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -26,2 +26,3 @@ ;((global, fn) => { | ||
} | ||
init.data = init.body | ||
init = Object.assign( | ||
@@ -28,0 +29,0 @@ { |
@@ -1,1 +0,1 @@ | ||
((a,b)=>{a.gmfetch=b("undefined"==typeof GM?{}:GM)})(this,a=>{if("undefined"==typeof GM_xmlhttpRequest&&"undefined"==typeof a.xmlHttpRequest)throw new Error("Either GM_xmlhttpRequest or GM.xmlHttpRequest must exists!");"function"!=typeof GM_xmlhttpRequest||a.xmlHttpRequest||(a.xmlHttpRequest=GM_xmlhttpRequest);const b=a=>a.reduce((a,[b,c])=>(a[b]=c,a),{}),c=a=>b(a.split("\n").filter(Boolean).map(a=>a.split(":").map(a=>a.trim()))),d=(e,f={})=>e instanceof Request?d(e.url,Object.assign({},e,f)):new Promise(d=>{f.headers instanceof Headers&&(f.headers=b(Array.from(f.headers.entries()))),f=Object.assign({method:"GET",headers:{}},f,{url:e,responseType:"blob"}),a.xmlHttpRequest(Object.assign({},f,{onload:a=>{a.headers=c(a.responseHeaders),d(new Response(a.response,Object.assign({},f,a)))},onerror:a=>{console.log("err",a),d(new Response(a.response,Object.assign({},f,a)))}}))});return d}); | ||
((a,b)=>{a.gmfetch=b("undefined"==typeof GM?{}:GM)})(this,a=>{if("undefined"==typeof GM_xmlhttpRequest&&"undefined"==typeof a.xmlHttpRequest)throw new Error("Either GM_xmlhttpRequest or GM.xmlHttpRequest must exists!");"function"!=typeof GM_xmlhttpRequest||a.xmlHttpRequest||(a.xmlHttpRequest=GM_xmlhttpRequest);const b=a=>a.reduce((a,[b,c])=>(a[b]=c,a),{}),c=a=>b(a.split("\n").filter(Boolean).map(a=>a.split(":").map(a=>a.trim()))),d=(e,f={})=>e instanceof Request?d(e.url,Object.assign({},e,f)):new Promise(d=>{f.headers instanceof Headers&&(f.headers=b(Array.from(f.headers.entries()))),f.data=f.body,f=Object.assign({method:"GET",headers:{}},f,{url:e,responseType:"blob"}),a.xmlHttpRequest(Object.assign({},f,{onload:a=>{a.headers=c(a.responseHeaders),d(new Response(a.response,Object.assign({},f,a)))},onerror:a=>{console.log("err",a),d(new Response(a.response,Object.assign({},f,a)))}}))});return d}); |
{ | ||
"name": "gmxhr-fetch", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "fetch-like wrapper for GM_xmlhttpRequest.", | ||
@@ -5,0 +5,0 @@ "main": "gmxhr-fetch.js", |
3096
53