Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.2.7 to 1.2.8

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=r(1),n=r(3),i=n.fetchDecorator;t.exports={fetch:i(o)}},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 f(t){var e=new FileReader;return e.readAsText(t),a(e)}function c(){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 f(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)},c.call(l.prototype),c.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";function o(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function n(t,e){var r={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}var i=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},a="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},s=r(4),f=r(9),c=r(10),u=function(t){return t},l={},p="",d=function(t){return t},y=function(t){return t instanceof Headers?function(){return Array.from(t.keys()).reduce(function(e,r){return e[r]=t.get(r),e},{})}():t},h=function(t,e,r){var o=e.ssl,n=(e.method,e.query);return"function"==typeof r?r(t,e):("string"==typeof r&&(t=t.replace(/^\/\//,r)),/^\/\//.test(t)&&(t=(o?"https":"http")+":"+t),n&&(t+=""+(t.match(/\?/)?"&":"?")+s.stringify(n)),t)},b=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.method,o=void 0===r?"GET":r,u=e.query,d=void 0===u?{}:u,b=e.data,m=void 0===b?{}:b,v=e.body,w=void 0===v?{}:v,g=e.headers,O=void 0===g?{}:g,j=(e.json,n(e,["method","query","data","body","headers","json"])),x="GET"===o||"HEAD"===o,E="undefined"!=typeof window&&w instanceof FormData;if(x?d="object"===("undefined"==typeof d?"undefined":a(d))?i({},d,m,w):0===Object.keys(d).length?m:d:w="object"!==("undefined"==typeof w?"undefined":a(w))||E?0!==Object.keys(w).length||E?w:m:i({},m,w),O=new Headers(i({},y(O),y(l))),x?"":O.set("Content-Type",O.get("Content-Type")||f(w)),"object"===("undefined"==typeof w?"undefined":a(w)))switch(O.get("Content-Type")){case c.form:w=s.stringify(w);break;case c.formData:var A=function(){var t=new FormData;return Object.keys(w).forEach(function(e){t.set(e,w[e])}),w=t,"break"}();if("break"===A)break}var T=i({method:o,query:d,headers:O},j);return x||(T.body=w),[h(t,T,p),T]},m=function(t){var e=function(){return t.call.apply(t,[void 0].concat(o(b.apply(void 0,arguments)))).then(d).then(u)};return e.callback=function(t){"function"==typeof t&&(u=t),delete e.callback},e.baseHost=function(t){p=t},e.headers=function(t){if("object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t)throw new Error("global headers must be object or function");l=t,delete e.headers},e};t.exports={fetchDecorator:m}},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},f=function t(e,r,n,i,a,s,f,c,u,l,p){var d=e;if("function"==typeof f)d=f(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(f))h=f;else{var b=Object.keys(d);h=c?b.sort(c):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,f,c,u,l,p)):y.concat(t(d[v],r+(u?"."+v:"["+v+"]"),n,i,a,s,f,c,u,l,p)))}return y};t.exports=function(t,e){var r=t,o=e||{},a="undefined"==typeof o.delimiter?s.delimiter:o.delimiter,c="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(f(r[x],x,O,c,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,f=o[i],c=f.indexOf("]=")===-1?f.indexOf("="):f.indexOf("]=")+1;c===-1?(a=e.decoder(f),s=e.strictNullHandling?null:""):(a=e.decoder(f.slice(0,c)),s=e.decoder(f.slice(c+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},f=function(t,e,r){if(t){var o=r.allowDots?t.replace(/\.([^\.\[]+)/g,"[$1]"):t,i=/^([^\[\]]*)/,a=/(\[[^\[\]]*\])/g,f=i.exec(o),c=[];if(f[1]){if(!r.plainObjects&&n.call(Object.prototype,f[1])&&!r.allowPrototypes)return;c.push(f[1])}for(var u=0;null!==(f=a.exec(o))&&u<r.depth;)u+=1,(r.plainObjects||!n.call(Object.prototype,f[1].replace(/\[|\]/g,""))||r.allowPrototypes)&&c.push(f[1]);return f&&c.push("["+o.slice(f.index)+"]"),s(c,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):{},c=Object.keys(n),u=0;u<c.length;++u){var l=c[u],p=f(l,n[l],r);s=o.merge(s,p,r)}return o.compact(s)}},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(10),i=function(t,e){if("undefined"!=typeof window&&t instanceof FormData)return n.formData;if("string"==typeof t)try{if(JSON.parse(t))return n.json}catch(t){return n.text}return"object"===("undefined"==typeof t?"undefined":o(t))?e?n.json:n.form:n.text};t.exports=i},function(t,e){"use strict";t.exports={formData:"multipart/form-data",form:"application/x-www-form-urlencoded",json:"application/json",text:"text/plain"}}])});
!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=r(1),n=r(3),i=n.fetchDecorator;t.exports={fetch:i(o)}},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 m.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,r=a(e);return e.readAsArrayBuffer(t),r}function f(t){var e=new FileReader,r=a(e);return e.readAsText(t),r}function u(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function l(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(m.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(m.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(m.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(m.arrayBuffer&&m.blob&&w(t))this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!m.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!g(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=c(t)}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):m.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},m.blob&&(this.blob=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));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._bodyArrayBuffer?i(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(s)}),this.text=function(){var t=i(this);if(t)return t;if(this._bodyBlob)return f(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(u(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},m.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}function p(t){var e=t.toUpperCase();return j.indexOf(e)>-1?e:t}function d(t,e){e=e||{};var r=e.body;if("string"==typeof t)this.url=t;else{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||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}if(this.credentials=e.credentials||this.credentials||"omit",!e.headers&&this.headers||(this.headers=new n(e.headers)),this.method=p(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 y(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 h(t){var e=new n;return t.split("\r\n").forEach(function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}}),e}function b(t,e){e||(e={}),this.type="default",this.status="status"in e?e.status:200,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new n(e.headers),this.url=e.url||"",this._initBody(t)}if(!t.fetch){var m={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};if(m.arrayBuffer)var v=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],w=function(t){return t&&DataView.prototype.isPrototypeOf(t)},g=ArrayBuffer.isView||function(t){return t&&v.indexOf(Object.prototype.toString.call(t))>-1};n.prototype.append=function(t,o){t=e(t),o=r(o);var n=this.map[t];this.map[t]=n?n+","+o:o},n.prototype.delete=function(t){delete this.map[e(t)]},n.prototype.get=function(t){return t=e(t),this.has(t)?this.map[t]:null},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){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,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)},m.iterable&&(n.prototype[Symbol.iterator]=n.prototype.entries);var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];d.prototype.clone=function(){return new d(this,{body:this._bodyInit})},l.call(d.prototype),l.call(b.prototype),b.prototype.clone=function(){return new b(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new n(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:0,statusText:""});return t.type="error",t};var O=[301,302,303,307,308];b.redirect=function(t,e){if(O.indexOf(e)===-1)throw new RangeError("Invalid status code");return new b(null,{status:e,headers:{location:t}})},t.Headers=n,t.Request=d,t.Response=b,t.fetch=function(t,e){return new Promise(function(r,o){var n=new d(t,e),i=new XMLHttpRequest;i.onload=function(){var t={status:i.status,statusText:i.statusText,headers:h(i.getAllResponseHeaders()||"")};t.url="responseURL"in i?i.responseURL:t.headers.get("X-Request-URL");var e="response"in i?i.response:i.responseText;r(new b(e,t))},i.onerror=function(){o(new TypeError("Network request failed"))},i.ontimeout=function(){o(new TypeError("Network request failed"))},i.open(n.method,n.url,!0),"include"===n.credentials&&(i.withCredentials=!0),"responseType"in i&&m.blob&&(i.responseType="blob"),n.headers.forEach(function(t,e){i.setRequestHeader(e,t)}),i.send("undefined"==typeof n._bodyInit?null:n._bodyInit)})},t.fetch.polyfill=!0}}("undefined"!=typeof self?self:this)},function(t,e,r){"use strict";function o(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function n(t,e){var r={};for(var o in t)e.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o]);return r}var i=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},a="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},s=r(4),f=r(9),u=r(10),c=function(t){return t},l={},p="",d=function(t){return t},y=function(t){return t instanceof Headers?function(){return Array.from(t.keys()).reduce(function(e,r){return e[r]=t.get(r),e},{})}():t},h=function(t,e,r){var o=e.ssl,n=(e.method,e.query);return"function"==typeof r?r(t,e):("string"==typeof r&&(t=t.replace(/^\/\//,r)),/^\/\//.test(t)&&(t=(o?"https":"http")+":"+t),n&&(t+=""+(t.match(/\?/)?"&":"?")+s.stringify(n)),t)},b=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.method,o=void 0===r?"GET":r,c=e.query,d=void 0===c?{}:c,b=e.data,m=void 0===b?{}:b,v=e.body,w=void 0===v?{}:v,g=e.headers,j=void 0===g?{}:g,O=(e.json,n(e,["method","query","data","body","headers","json"])),A="GET"===o||"HEAD"===o,x="undefined"!=typeof window&&w instanceof FormData;if(A?d="object"===("undefined"==typeof d?"undefined":a(d))?i({},d,m,w):0===Object.keys(d).length?m:d:w="object"!==("undefined"==typeof w?"undefined":a(w))||x?0!==Object.keys(w).length||x?w:m:i({},m,w),j=new Headers(i({},y(j),y(l))),A?"":j.set("Content-Type",j.get("Content-Type")||f(w)),"object"===("undefined"==typeof w?"undefined":a(w)))switch(j.get("Content-Type")){case u.form:w=s.stringify(w);break;case u.formData:var E=function(){var t=new FormData;return Object.keys(w).forEach(function(e){t.set(e,w[e])}),w=t,"break"}();if("break"===E)break}var T=i({method:o,query:d,headers:j},O);return A||(T.body=w),[h(t,T,p),T]},m=function(t){var e=function(){return t.call.apply(t,[void 0].concat(o(b.apply(void 0,arguments)))).then(d).then(c)};return e.callback=function(t){"function"==typeof t&&(c=t),delete e.callback},e.baseHost=function(t){p=t},e.headers=function(t){if("object"!==("undefined"==typeof t?"undefined":a(t))&&"function"!=typeof t)throw new Error("global headers must be object or function");l=t,delete e.headers},e};t.exports={fetchDecorator:m}},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},f=function t(e,r,n,i,a,s,f,u,c,l,p){var d=e;if("function"==typeof f)d=f(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(f))h=f;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,f,u,c,l,p)):y.concat(t(d[v],r+(c?"."+v:"["+v+"]"),n,i,a,s,f,u,c,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,c="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 j=i[g];b||(b=Object.keys(r)),d&&b.sort(d);for(var O=0;O<b.length;++O){var A=b[O];c&&null===r[A]||(w=w.concat(f(r[A],A,j,u,c,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,f=o[i],u=f.indexOf("]=")===-1?f.indexOf("="):f.indexOf("]=")+1;u===-1?(a=e.decoder(f),s=e.strictNullHandling?null:""):(a=e.decoder(f.slice(0,u)),s=e.decoder(f.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},f=function(t,e,r){if(t){var o=r.allowDots?t.replace(/\.([^\.\[]+)/g,"[$1]"):t,i=/^([^\[\]]*)/,a=/(\[[^\[\]]*\])/g,f=i.exec(o),u=[];if(f[1]){if(!r.plainObjects&&n.call(Object.prototype,f[1])&&!r.allowPrototypes)return;u.push(f[1])}for(var c=0;null!==(f=a.exec(o))&&c<r.depth;)c+=1,(r.plainObjects||!n.call(Object.prototype,f[1].replace(/\[|\]/g,""))||r.allowPrototypes)&&u.push(f[1]);return f&&u.push("["+o.slice(f.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),c=0;c<u.length;++c){var l=u[c],p=f(l,n[l],r);s=o.merge(s,p,r)}return o.compact(s)}},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(10),i=function(t,e){if("undefined"!=typeof window&&t instanceof FormData)return n.formData;if("string"==typeof t)try{if(JSON.parse(t))return n.json}catch(t){return n.text}return"object"===("undefined"==typeof t?"undefined":o(t))?e?n.json:n.form:n.text};t.exports=i},function(t,e){"use strict";t.exports={formData:"multipart/form-data",form:"application/x-www-form-urlencoded",json:"application/json",text:"text/plain"}}])});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguYnJvd3Nlci5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9pbmRleC5icm93c2VyLmpzIl0sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIifQ==
{
"name": "autofetch",
"version": "1.2.7",
"version": "1.2.8",
"description": "fetch for node",

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

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

module.exports = fetchDecorator(realFetch);
const fetch = fetchDecorator(realFetch);
fetch.fetch = fetch;
module.exports = fetch;
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