Socket
Socket
Sign inDemoInstall

autofetch

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autofetch - npm Package Compare versions

Comparing version 1.0.19 to 1.0.20

2

dist/index.browser.js

@@ -1,2 +0,2 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";var o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},n=r(1),i=r(3),a=i.responseMiddleware,s=i.parseUrl,c=i.toFormData,f=function(t){return t},u="",l=function(t){for(var e=arguments.length,r=Array(e>2?e-2:0),i=2;i<e;i++)r[i-2]=arguments[i];var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l.data?"GET"===l.method?l.query=o({},l.query||{},l.data):l.body=o({},l.body||{},l.data):"",l.method&&"GET"!==l.method||(l.body=l.body||l.data),l.headers=l.headers||{},"application/json"===l.headers["Content-Type"]||"multipart/form-data"===l.headers["Content-Type"]||"string"==typeof l.body||l.body instanceof FormData||(l.body=c(l.body),l.headers["Content-Type"]="application/x-www-form-urlencoded"),n.call.apply(n,[void 0,s(t,l,u),l].concat(r)).then(a).then(f)};l.callback=function(t){"function"==typeof t&&(f=t),delete l.callback},l.baseHost=function(t){u=t},t.exports={fetch:l}},function(t,e,r){r(2),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return h.iterable&&(e[Symbol.iterator]=function(){return e}),e}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function a(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function s(t){var e=new FileReader;return e.readAsArrayBuffer(t),a(e)}function c(t){var e=new FileReader;return e.readAsText(t),a(e)}function f(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(h.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(h.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(h.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!h.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):h.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},h.blob?(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(s)},this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return c(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=i(this);return t?t:Promise.resolve(this._bodyText)},h.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function u(t){var e=t.toUpperCase();return b.indexOf(e)>-1?e:t}function l(t,e){e=e||{};var r=e.body;if(l.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new n(e.headers)),this.method=u(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function d(t){var e=new n,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function y(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof n?e.headers:new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var h={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};n.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},n.prototype.delete=function(t){delete this.map[e(t)]},n.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},n.prototype.getAll=function(t){return this.map[e(t)]||[]},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},n.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)},n.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),o(t)},n.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},n.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),o(t)},h.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];l.prototype.clone=function(){return new l(this)},f.call(l.prototype),f.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];y.redirect=function(t,e){if(m.indexOf(e)===-1)throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=l,t.Response=y,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in a?a.responseURL:/^X-Request-URL:/m.test(a.getAllResponseHeaders())?a.getResponseHeader("X-Request-URL"):void 0}var i;i=l.prototype.isPrototypeOf(t)&&!e?t:new l(t,e);var a=new XMLHttpRequest;a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:d(a),url:n()},e="response"in a?a.response:a.responseText;r(new y(e,t))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.open(i.method,i.url,!0),"include"===i.credentials&&(a.withCredentials=!0),"responseType"in a&&h.blob&&(a.responseType="blob"),i.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),a.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(t,e,r){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=r(4),i=function(t){return t},a=function(t,e,r){var n=e.ssl,i=e.method,a=e.body,s=e.query;return"function"==typeof r&&(t=r(t)),"string"==typeof r&&(t=t.replace(/^\/\//,r)),/^\/\//.test(t)&&(t=(n?"https":"http")+":"+t),"object"!==("undefined"==typeof a?"undefined":o(a))&&"object"!==("undefined"==typeof s?"undefined":o(s))||i&&"GET"!==i||!function(){var e=s||a;t+=""+(t.match(/\?/)?"":"?")+Object.keys(e).map(function(t){return t+"="+e[t]}).join("&")}(),t},s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n.stringify(t)};t.exports={parseUrl:a,responseMiddleware:i,toFormData:s}},function(t,e,r){"use strict";var o=r(5),n=r(8),i=r(7);t.exports={formats:i,parse:n,stringify:o}},function(t,e,r){"use strict";var o=r(6),n=r(7),i={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},a=Date.prototype.toISOString,s={delimiter:"&",encode:!0,encoder:o.encode,serializeDate:function(t){return a.call(t)},skipNulls:!1,strictNullHandling:!1},c=function t(e,r,n,i,a,s,c,f,u,l,p){var d=e;if("function"==typeof c)d=c(r,d);else if(d instanceof Date)d=l(d);else if(null===d){if(i)return s?s(r):r;d=""}if("string"==typeof d||"number"==typeof d||"boolean"==typeof d||o.isBuffer(d))return s?[p(s(r))+"="+p(s(d))]:[p(r)+"="+p(String(d))];var y=[];if("undefined"==typeof d)return y;var h;if(Array.isArray(c))h=c;else{var b=Object.keys(d);h=f?b.sort(f):b}for(var m=0;m<h.length;++m){var v=h[m];a&&null===d[v]||(y=Array.isArray(d)?y.concat(t(d[v],n(r,v),n,i,a,s,c,f,u,l,p)):y.concat(t(d[v],r+(u?"."+v:"["+v+"]"),n,i,a,s,c,f,u,l,p)))}return y};t.exports=function(t,e){var r=t,o=e||{},a="undefined"==typeof o.delimiter?s.delimiter:o.delimiter,f="boolean"==typeof o.strictNullHandling?o.strictNullHandling:s.strictNullHandling,u="boolean"==typeof o.skipNulls?o.skipNulls:s.skipNulls,l="boolean"==typeof o.encode?o.encode:s.encode,p=l?"function"==typeof o.encoder?o.encoder:s.encoder:null,d="function"==typeof o.sort?o.sort:null,y="undefined"!=typeof o.allowDots&&o.allowDots,h="function"==typeof o.serializeDate?o.serializeDate:s.serializeDate;if("undefined"==typeof o.format)o.format=n.default;else if(!Object.prototype.hasOwnProperty.call(n.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,m,v=n.formatters[o.format];if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof o.filter?(m=o.filter,r=m("",r)):Array.isArray(o.filter)&&(m=o.filter,b=m);var w=[];if("object"!=typeof r||null===r)return"";var g;g=o.arrayFormat in i?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var O=i[g];b||(b=Object.keys(r)),d&&b.sort(d);for(var j=0;j<b.length;++j){var x=b[j];u&&null===r[x]||(w=w.concat(c(r[x],x,O,f,u,p,m,d,y,h,v)))}return w.join(a)}},function(t,e){"use strict";var r=Object.prototype.hasOwnProperty,o=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}();e.arrayToObject=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},o=0;o<t.length;++o)"undefined"!=typeof t[o]&&(r[o]=t[o]);return r},e.merge=function(t,o,n){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];t[o]=!0}return t}if("object"!=typeof t)return[t].concat(o);var i=t;return Array.isArray(t)&&!Array.isArray(o)&&(i=e.arrayToObject(t,n)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,i){r.call(t,i)?t[i]&&"object"==typeof t[i]?t[i]=e.merge(t[i],o,n):t.push(o):t[i]=o}),t):Object.keys(o).reduce(function(t,r){var i=o[r];return Object.prototype.hasOwnProperty.call(t,r)?t[r]=e.merge(t[r],i,n):t[r]=i,t},i)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),r="",n=0;n<e.length;++n){var i=e.charCodeAt(n);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?r+=e.charAt(n):i<128?r+=o[i]:i<2048?r+=o[192|i>>6]+o[128|63&i]:i<55296||i>=57344?r+=o[224|i>>12]+o[128|i>>6&63]+o[128|63&i]:(n+=1,i=65536+((1023&i)<<10|1023&e.charCodeAt(n)),r+=o[240|i>>18]+o[128|i>>12&63]+o[128|i>>6&63]+o[128|63&i])}return r},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;var o=r||[],n=o.indexOf(t);if(n!==-1)return o[n];if(o.push(t),Array.isArray(t)){for(var i=[],a=0;a<t.length;++a)t[a]&&"object"==typeof t[a]?i.push(e.compact(t[a],o)):"undefined"!=typeof t[a]&&i.push(t[a]);return i}var s=Object.keys(t);return s.forEach(function(r){t[r]=e.compact(t[r],o)}),t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!==t&&"undefined"!=typeof t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e){"use strict";var r=String.prototype.replace,o=/%20/g;t.exports={default:"RFC3986",formatters:{RFC1738:function(t){return r.call(t,o,"+")},RFC3986:function(t){return t}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(t,e,r){"use strict";var o=r(6),n=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:o.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(t,e){for(var r={},o=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),i=0;i<o.length;++i){var a,s,c=o[i],f=c.indexOf("]=")===-1?c.indexOf("="):c.indexOf("]=")+1;f===-1?(a=e.decoder(c),s=e.strictNullHandling?null:""):(a=e.decoder(c.slice(0,f)),s=e.decoder(c.slice(f+1))),n.call(r,a)?r[a]=[].concat(r[a]).concat(s):r[a]=s}return r},s=function t(e,r,o){if(!e.length)return r;var n,i=e.shift();if("[]"===i)n=[],n=n.concat(t(e,r,o));else{n=o.plainObjects?Object.create(null):{};var a="["===i[0]&&"]"===i[i.length-1]?i.slice(1,i.length-1):i,s=parseInt(a,10);!isNaN(s)&&i!==a&&String(s)===a&&s>=0&&o.parseArrays&&s<=o.arrayLimit?(n=[],n[s]=t(e,r,o)):n[a]=t(e,r,o)}return n},c=function(t,e,r){if(t){var o=r.allowDots?t.replace(/\.([^\.\[]+)/g,"[$1]"):t,i=/^([^\[\]]*)/,a=/(\[[^\[\]]*\])/g,c=i.exec(o),f=[];if(c[1]){if(!r.plainObjects&&n.call(Object.prototype,c[1])&&!r.allowPrototypes)return;f.push(c[1])}for(var u=0;null!==(c=a.exec(o))&&u<r.depth;)u+=1,(r.plainObjects||!n.call(Object.prototype,c[1].replace(/\[|\]/g,""))||r.allowPrototypes)&&f.push(c[1]);return c&&f.push("["+o.slice(c.index)+"]"),s(f,e,r)}};t.exports=function(t,e){var r=e||{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.delimiter="string"==typeof r.delimiter||o.isRegExp(r.delimiter)?r.delimiter:i.delimiter,r.depth="number"==typeof r.depth?r.depth:i.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:i.arrayLimit,r.parseArrays=r.parseArrays!==!1,r.decoder="function"==typeof r.decoder?r.decoder:i.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:i.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:i.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:i.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:i.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:i.strictNullHandling,""===t||null===t||"undefined"==typeof t)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof t?a(t,r):t,s=r.plainObjects?Object.create(null):{},f=Object.keys(n),u=0;u<f.length;++u){var l=f[u],p=c(l,n[l],r);s=o.merge(s,p,r)}return o.compact(s)}}])});
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var o in r)("object"==typeof exports?exports:t)[o]=r[o]}}(this,function(){return function(t){function e(o){if(r[o])return r[o].exports;var n=r[o]={exports:{},id:o,loaded:!1};return t[o].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";var o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},n=r(1),i=r(3),a=i.responseMiddleware,s=i.parseUrl,c=i.toFormData,u=function(t){return t},f="",l=function(t){for(var e=arguments.length,r=Array(e>2?e-2:0),i=2;i<e;i++)r[i-2]=arguments[i];var l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return l.data?"GET"===l.method||"HEAD"===l.method?l.query=o({},l.query||{},l.data):l.body=o({},l.body||{},l.data):"",l.method&&"GET"!==l.method||(l.query=l.body||l.data),l.headers=l.headers||{},"application/json"===l.headers["Content-Type"]||"multipart/form-data"===l.headers["Content-Type"]||"string"==typeof l.body||l.body instanceof FormData||(l.body=c(l.body),l.headers["Content-Type"]="application/x-www-form-urlencoded"),l.method&&"GET"!==l.method&&"HEAD"!==l.method||!l.body||delete l.body,n.call.apply(n,[void 0,s(t,l,f),l].concat(r)).then(a).then(u)};l.callback=function(t){"function"==typeof t&&(u=t),delete l.callback},l.baseHost=function(t){f=t},t.exports={fetch:l}},function(t,e,r){r(2),t.exports=self.fetch.bind(self)},function(t,e){!function(t){"use strict";function e(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function r(t){return"string"!=typeof t&&(t=String(t)),t}function o(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return h.iterable&&(e[Symbol.iterator]=function(){return e}),e}function n(t){this.map={},t instanceof n?t.forEach(function(t,e){this.append(e,t)},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function i(t){return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function a(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function s(t){var e=new FileReader;return e.readAsArrayBuffer(t),a(e)}function c(t){var e=new FileReader;return e.readAsText(t),a(e)}function u(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,"string"==typeof t)this._bodyText=t;else if(h.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(h.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(h.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(t){if(!h.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t))throw new Error("unsupported BodyInit type")}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):h.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},h.blob?(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this.blob().then(s)},this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return c(this._bodyBlob);if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)}):this.text=function(){var t=i(this);return t?t:Promise.resolve(this._bodyText)},h.formData&&(this.formData=function(){return this.text().then(p)}),this.json=function(){return this.text().then(JSON.parse)},this}function f(t){var e=t.toUpperCase();return b.indexOf(e)>-1?e:t}function l(t,e){e=e||{};var r=e.body;if(l.prototype.isPrototypeOf(t)){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new n(t.headers)),this.method=t.method,this.mode=t.mode,r||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=t;if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new n(e.headers)),this.method=f(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function p(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}}),e}function d(t){var e=new n,r=(t.getAllResponseHeaders()||"").trim().split("\n");return r.forEach(function(t){var r=t.trim().split(":"),o=r.shift().trim(),n=r.join(":").trim();e.append(o,n)}),e}function y(t,e){e||(e={}),this.type="default",this.status=e.status,this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText,this.headers=e.headers instanceof n?e.headers:new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var h={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};n.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];n||(n=[],this.map[t]=n),n.push(o)},n.prototype.delete=function(t){delete this.map[e(t)]},n.prototype.get=function(t){var r=this.map[e(t)];return r?r[0]:null},n.prototype.getAll=function(t){return this.map[e(t)]||[]},n.prototype.has=function(t){return this.map.hasOwnProperty(e(t))},n.prototype.set=function(t,o){this.map[e(t)]=[r(o)]},n.prototype.forEach=function(t,e){Object.getOwnPropertyNames(this.map).forEach(function(r){this.map[r].forEach(function(o){t.call(e,o,r,this)},this)},this)},n.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),o(t)},n.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),o(t)},n.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),o(t)},h.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];l.prototype.clone=function(){return new l(this)},u.call(l.prototype),u.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var m=[301,302,303,307,308];y.redirect=function(t,e){if(m.indexOf(e)===-1)throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=l,t.Response=y,t.fetch=function(t,e){return new Promise(function(r,o){function n(){return"responseURL"in a?a.responseURL:/^X-Request-URL:/m.test(a.getAllResponseHeaders())?a.getResponseHeader("X-Request-URL"):void 0}var i;i=l.prototype.isPrototypeOf(t)&&!e?t:new l(t,e);var a=new XMLHttpRequest;a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:d(a),url:n()},e="response"in a?a.response:a.responseText;r(new y(e,t))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.open(i.method,i.url,!0),"include"===i.credentials&&(a.withCredentials=!0),"responseType"in a&&h.blob&&(a.responseType="blob"),i.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),a.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(t,e,r){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n=r(4),i=function(t){return t},a=function(t,e,r){var n=e.ssl,i=e.method,a=e.body,s=e.query;return"function"==typeof r&&(t=r(t)),"string"==typeof r&&(t=t.replace(/^\/\//,r)),/^\/\//.test(t)&&(t=(n?"https":"http")+":"+t),"object"!==("undefined"==typeof a?"undefined":o(a))&&"object"!==("undefined"==typeof s?"undefined":o(s))||i&&"GET"!==i||!function(){var e=s||a;t+=""+(t.match(/\?/)?"":"?")+Object.keys(e).map(function(t){return t+"="+e[t]}).join("&")}(),t},s=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n.stringify(t)};t.exports={parseUrl:a,responseMiddleware:i,toFormData:s}},function(t,e,r){"use strict";var o=r(5),n=r(8),i=r(7);t.exports={formats:i,parse:n,stringify:o}},function(t,e,r){"use strict";var o=r(6),n=r(7),i={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},a=Date.prototype.toISOString,s={delimiter:"&",encode:!0,encoder:o.encode,serializeDate:function(t){return a.call(t)},skipNulls:!1,strictNullHandling:!1},c=function t(e,r,n,i,a,s,c,u,f,l,p){var d=e;if("function"==typeof c)d=c(r,d);else if(d instanceof Date)d=l(d);else if(null===d){if(i)return s?s(r):r;d=""}if("string"==typeof d||"number"==typeof d||"boolean"==typeof d||o.isBuffer(d))return s?[p(s(r))+"="+p(s(d))]:[p(r)+"="+p(String(d))];var y=[];if("undefined"==typeof d)return y;var h;if(Array.isArray(c))h=c;else{var b=Object.keys(d);h=u?b.sort(u):b}for(var m=0;m<h.length;++m){var v=h[m];a&&null===d[v]||(y=Array.isArray(d)?y.concat(t(d[v],n(r,v),n,i,a,s,c,u,f,l,p)):y.concat(t(d[v],r+(f?"."+v:"["+v+"]"),n,i,a,s,c,u,f,l,p)))}return y};t.exports=function(t,e){var r=t,o=e||{},a="undefined"==typeof o.delimiter?s.delimiter:o.delimiter,u="boolean"==typeof o.strictNullHandling?o.strictNullHandling:s.strictNullHandling,f="boolean"==typeof o.skipNulls?o.skipNulls:s.skipNulls,l="boolean"==typeof o.encode?o.encode:s.encode,p=l?"function"==typeof o.encoder?o.encoder:s.encoder:null,d="function"==typeof o.sort?o.sort:null,y="undefined"!=typeof o.allowDots&&o.allowDots,h="function"==typeof o.serializeDate?o.serializeDate:s.serializeDate;if("undefined"==typeof o.format)o.format=n.default;else if(!Object.prototype.hasOwnProperty.call(n.formatters,o.format))throw new TypeError("Unknown format option provided.");var b,m,v=n.formatters[o.format];if(null!==o.encoder&&void 0!==o.encoder&&"function"!=typeof o.encoder)throw new TypeError("Encoder has to be a function.");"function"==typeof o.filter?(m=o.filter,r=m("",r)):Array.isArray(o.filter)&&(m=o.filter,b=m);var w=[];if("object"!=typeof r||null===r)return"";var g;g=o.arrayFormat in i?o.arrayFormat:"indices"in o?o.indices?"indices":"repeat":"indices";var O=i[g];b||(b=Object.keys(r)),d&&b.sort(d);for(var j=0;j<b.length;++j){var x=b[j];f&&null===r[x]||(w=w.concat(c(r[x],x,O,u,f,p,m,d,y,h,v)))}return w.join(a)}},function(t,e){"use strict";var r=Object.prototype.hasOwnProperty,o=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}();e.arrayToObject=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},o=0;o<t.length;++o)"undefined"!=typeof t[o]&&(r[o]=t[o]);return r},e.merge=function(t,o,n){if(!o)return t;if("object"!=typeof o){if(Array.isArray(t))t.push(o);else{if("object"!=typeof t)return[t,o];t[o]=!0}return t}if("object"!=typeof t)return[t].concat(o);var i=t;return Array.isArray(t)&&!Array.isArray(o)&&(i=e.arrayToObject(t,n)),Array.isArray(t)&&Array.isArray(o)?(o.forEach(function(o,i){r.call(t,i)?t[i]&&"object"==typeof t[i]?t[i]=e.merge(t[i],o,n):t.push(o):t[i]=o}),t):Object.keys(o).reduce(function(t,r){var i=o[r];return Object.prototype.hasOwnProperty.call(t,r)?t[r]=e.merge(t[r],i,n):t[r]=i,t},i)},e.decode=function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},e.encode=function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),r="",n=0;n<e.length;++n){var i=e.charCodeAt(n);45===i||46===i||95===i||126===i||i>=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122?r+=e.charAt(n):i<128?r+=o[i]:i<2048?r+=o[192|i>>6]+o[128|63&i]:i<55296||i>=57344?r+=o[224|i>>12]+o[128|i>>6&63]+o[128|63&i]:(n+=1,i=65536+((1023&i)<<10|1023&e.charCodeAt(n)),r+=o[240|i>>18]+o[128|i>>12&63]+o[128|i>>6&63]+o[128|63&i])}return r},e.compact=function(t,r){if("object"!=typeof t||null===t)return t;var o=r||[],n=o.indexOf(t);if(n!==-1)return o[n];if(o.push(t),Array.isArray(t)){for(var i=[],a=0;a<t.length;++a)t[a]&&"object"==typeof t[a]?i.push(e.compact(t[a],o)):"undefined"!=typeof t[a]&&i.push(t[a]);return i}var s=Object.keys(t);return s.forEach(function(r){t[r]=e.compact(t[r],o)}),t},e.isRegExp=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},e.isBuffer=function(t){return null!==t&&"undefined"!=typeof t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))}},function(t,e){"use strict";var r=String.prototype.replace,o=/%20/g;t.exports={default:"RFC3986",formatters:{RFC1738:function(t){return r.call(t,o,"+")},RFC3986:function(t){return t}},RFC1738:"RFC1738",RFC3986:"RFC3986"}},function(t,e,r){"use strict";var o=r(6),n=Object.prototype.hasOwnProperty,i={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:o.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},a=function(t,e){for(var r={},o=t.split(e.delimiter,e.parameterLimit===1/0?void 0:e.parameterLimit),i=0;i<o.length;++i){var a,s,c=o[i],u=c.indexOf("]=")===-1?c.indexOf("="):c.indexOf("]=")+1;u===-1?(a=e.decoder(c),s=e.strictNullHandling?null:""):(a=e.decoder(c.slice(0,u)),s=e.decoder(c.slice(u+1))),n.call(r,a)?r[a]=[].concat(r[a]).concat(s):r[a]=s}return r},s=function t(e,r,o){if(!e.length)return r;var n,i=e.shift();if("[]"===i)n=[],n=n.concat(t(e,r,o));else{n=o.plainObjects?Object.create(null):{};var a="["===i[0]&&"]"===i[i.length-1]?i.slice(1,i.length-1):i,s=parseInt(a,10);!isNaN(s)&&i!==a&&String(s)===a&&s>=0&&o.parseArrays&&s<=o.arrayLimit?(n=[],n[s]=t(e,r,o)):n[a]=t(e,r,o)}return n},c=function(t,e,r){if(t){var o=r.allowDots?t.replace(/\.([^\.\[]+)/g,"[$1]"):t,i=/^([^\[\]]*)/,a=/(\[[^\[\]]*\])/g,c=i.exec(o),u=[];if(c[1]){if(!r.plainObjects&&n.call(Object.prototype,c[1])&&!r.allowPrototypes)return;u.push(c[1])}for(var f=0;null!==(c=a.exec(o))&&f<r.depth;)f+=1,(r.plainObjects||!n.call(Object.prototype,c[1].replace(/\[|\]/g,""))||r.allowPrototypes)&&u.push(c[1]);return c&&u.push("["+o.slice(c.index)+"]"),s(u,e,r)}};t.exports=function(t,e){var r=e||{};if(null!==r.decoder&&void 0!==r.decoder&&"function"!=typeof r.decoder)throw new TypeError("Decoder has to be a function.");if(r.delimiter="string"==typeof r.delimiter||o.isRegExp(r.delimiter)?r.delimiter:i.delimiter,r.depth="number"==typeof r.depth?r.depth:i.depth,r.arrayLimit="number"==typeof r.arrayLimit?r.arrayLimit:i.arrayLimit,r.parseArrays=r.parseArrays!==!1,r.decoder="function"==typeof r.decoder?r.decoder:i.decoder,r.allowDots="boolean"==typeof r.allowDots?r.allowDots:i.allowDots,r.plainObjects="boolean"==typeof r.plainObjects?r.plainObjects:i.plainObjects,r.allowPrototypes="boolean"==typeof r.allowPrototypes?r.allowPrototypes:i.allowPrototypes,r.parameterLimit="number"==typeof r.parameterLimit?r.parameterLimit:i.parameterLimit,r.strictNullHandling="boolean"==typeof r.strictNullHandling?r.strictNullHandling:i.strictNullHandling,""===t||null===t||"undefined"==typeof t)return r.plainObjects?Object.create(null):{};for(var n="string"==typeof t?a(t,r):t,s=r.plainObjects?Object.create(null):{},u=Object.keys(n),f=0;f<u.length;++f){var l=u[f],p=c(l,n[l],r);s=o.merge(s,p,r)}return o.compact(s)}}])});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguYnJvd3Nlci5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9pbmRleC5icm93c2VyLmpzIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==
{
"name": "autofetch",
"version": "1.0.19",
"version": "1.0.20",
"description": "fetch for node",

@@ -5,0 +5,0 @@ "main": "src/index.node.js",

@@ -8,6 +8,6 @@ const realFetch = require('isomorphic-fetch/fetch-npm-browserify.js');

const fetchRequest = (url, options = {}, ...extras) => {
options.data ? options.method === 'GET' ? options.query = { ...(options.query || {}), ...options.data } : options.body = { ...(options.body || {}), ...options.data } : '';
options.data ? (options.method === 'GET' || options.method === 'HEAD') ? options.query = { ...(options.query || {}), ...options.data } : options.body = { ...(options.body || {}), ...options.data } : '';
if (!options.method || options.method === 'GET') {
options.body = options.body || options.data;
options.query = options.body || options.data;
}

@@ -23,2 +23,6 @@

if ((!options.method || options.method === 'GET' || options.method === 'HEAD') && options.body) {
delete options.body;
}
return realFetch.call(this, parseUrl(url, options, baseHost), options, ...extras).then(responseMiddleware).then(globalCallback);

@@ -25,0 +29,0 @@ };

@@ -10,6 +10,6 @@ "use strict";

const fetchRequest = (url, options = {}, ...extras) => {
options.data ? options.method === 'GET' ? options.query = { ...(options.query || {}), ...options.data } : options.body = { ...(options.body || {}), ...options.data } : '';
options.data ? (options.method === 'GET' || options.method === 'HEAD') ? options.query = { ...(options.query || {}), ...options.data } : options.body = { ...(options.body || {}), ...options.data } : '';
if (!options.method || options.method === 'GET') {
options.body = options.body || options.data;
options.query = options.body || options.data;
}

@@ -25,2 +25,6 @@

if ((!options.method || options.method === 'GET' || options.method === 'HEAD') && options.body) {
delete options.body;
}
return realFetch.call(this, parseUrl(url, options, baseHost), options, ...extras).then(responseMiddleware).then(globalCallback);

@@ -27,0 +31,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc