From 6f141082aec9af65561ebd360bb61dbdee9fc71b Mon Sep 17 00:00:00 2001 From: Filipe Deschamps Date: Tue, 29 Sep 2020 20:08:25 -0700 Subject: [PATCH 1/2] services: add node-fetch timeout --- src/services/brasilapi.js | 3 ++- src/services/correios.js | 3 ++- src/services/viacep.js | 3 ++- src/services/widenet.js | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/services/brasilapi.js b/src/services/brasilapi.js index 3361c6f..655bfa6 100644 --- a/src/services/brasilapi.js +++ b/src/services/brasilapi.js @@ -10,7 +10,8 @@ export default function fetchBrasilAPIService (cepWithLeftPad) { mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000, } return fetch(url, options) diff --git a/src/services/correios.js b/src/services/correios.js index e8d813b..b443d6c 100644 --- a/src/services/correios.js +++ b/src/services/correios.js @@ -11,7 +11,8 @@ export default function fetchCorreiosService (cepWithLeftPad, proxyURL = '') { headers: { 'Content-Type': 'text/xml;charset=UTF-8', 'cache-control': 'no-cache' - } + }, + timeout: 5000, } return fetch(url, options) diff --git a/src/services/viacep.js b/src/services/viacep.js index 2545887..02fc864 100644 --- a/src/services/viacep.js +++ b/src/services/viacep.js @@ -11,7 +11,8 @@ export default function fetchViaCepService (cepWithLeftPad, proxyURL = '') { headers: { 'content-type': 'application/json;charset=utf-8', 'user-agent': '' - } + }, + timeout: 2000, } return fetch(url, options) diff --git a/src/services/widenet.js b/src/services/widenet.js index d6b234e..cbfb048 100644 --- a/src/services/widenet.js +++ b/src/services/widenet.js @@ -10,7 +10,8 @@ export default function fetchWideNetService (cepWithLeftPad, proxyURL = '') { mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000, } return fetch(url, options) From a16b0aae71456b09e9ab7cb271c3c0e6b41eb0be Mon Sep 17 00:00:00 2001 From: Filipe Deschamps Date: Tue, 29 Sep 2020 20:08:40 -0700 Subject: [PATCH 2/2] chore: build files --- dist/cep-promise-browser.js | 12 ++++++++---- dist/cep-promise-browser.min.js | 2 +- dist/cep-promise.js | 12 ++++++++---- dist/cep-promise.min.js | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dist/cep-promise-browser.js b/dist/cep-promise-browser.js index 8495f74..9266d65 100644 --- a/dist/cep-promise-browser.js +++ b/dist/cep-promise-browser.js @@ -360,7 +360,8 @@ headers: { 'Content-Type': 'text/xml;charset=UTF-8', 'cache-control': 'no-cache' - } + }, + timeout: 5000 }; return fetch(url, options).then(analyzeAndParseResponse)["catch"](throwApplicationError); } @@ -443,7 +444,8 @@ headers: { 'content-type': 'application/json;charset=utf-8', 'user-agent': '' - } + }, + timeout: 2000 }; return fetch(url, options).then(analyzeAndParseResponse$1).then(checkForViaCepError).then(extractCepValuesFromResponse)["catch"](throwApplicationError$1); } @@ -496,7 +498,8 @@ mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000 }; return fetch(url, options).then(analyzeAndParseResponse$2).then(checkForWideNetError).then(extractCepValuesFromResponse$1)["catch"](throwApplicationError$2); } @@ -548,7 +551,8 @@ mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000 }; return fetch(url, options).then(parseResponse).then(extractCepValuesFromResponse$2)["catch"](throwApplicationError$3); } diff --git a/dist/cep-promise-browser.min.js b/dist/cep-promise-browser.min.js index c678d2d..e93cea6 100644 --- a/dist/cep-promise-browser.min.js +++ b/dist/cep-promise-browser.min.js @@ -1 +1 @@ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).cep=r()}(this,function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function s(e,r,t){return(s=a()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&i(o,t.prototype),o}).apply(null,arguments)}function r(e){var n="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)})(e)}function u(e,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):r}function n(t){var n=a();return function(){var e,r=o(t);return u(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function f(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,r){if(e){if("string"==typeof e)return l(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,r):void 0}}function l(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t\n\n \n \n \n '.concat(e,"\n \n \n"),headers:{"Content-Type":"text/xml;charset=UTF-8","cache-control":"no-cache"}}).then(y).catch(P)}function y(e){return e.ok?e.text().then(b).then(E):e.text().then(g).then(w)}function b(e){try{var r;return(null!==(r=e.replace(/\r?\n|\r/g,"").match(/(.*)<\/return>/)[0])&&void 0!==r?r:"").replace("","").replace("","").split(/");return 1(.*)<\/faultstring>/)[0])&&void 0!==r?r:"").replace("","").replace("","")}catch(e){throw new Error("Não foi possível interpretar o XML de resposta.")}}function w(e){throw new Error(e)}function E(e){return{cep:e.cep,state:e.uf,city:e.cidade,neighborhood:e.bairro,street:e.end,service:"correios"}}function P(e){var r=new v({message:e.message,service:"correios"});throw"FetchError"===e.name&&(r.message="Erro ao se conectar com o serviço dos Correios."),r}function S(e){return h("".concat(1=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(!r.includes(o))throw new d({message:"Erro ao inicializar a instância do CepPromise.",type:"validation_error",errors:[{message:'O provider "'.concat(o,'" é inválido. Os providers disponíveis são: ["').concat(r.join('", "'),'"].'),service:"providers_validation"}]});return}}catch(e){n.e(e)}finally{n.f()}}(o.providers),e}).then(V).then(D).then(q).then(function(e){return r=e,t=o,n="undefined"!=typeof window?{viacep:S,widenet:A,brasilapi:F}:{correios:m,viacep:S,widenet:A,brasilapi:F},0!==t.providers.length?B.any(t.providers.map(function(e){return n[e](r)})):B.any(Object.values(n).map(function(e){return e(r)}));var r,t,n}).catch(G).catch(U)}}); \ No newline at end of file +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e=e||self).cep=r()}(this,function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function s(e,r,t){return(s=a()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&i(o,t.prototype),o}).apply(null,arguments)}function r(e){var n="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)})(e)}function u(e,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):r}function n(t){var n=a();return function(){var e,r=o(t);return u(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function f(e){return function(e){if(Array.isArray(e))return l(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||p(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(e,r){if(e){if("string"==typeof e)return l(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,r):void 0}}function l(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t\n\n \n \n \n '.concat(e,"\n \n \n"),headers:{"Content-Type":"text/xml;charset=UTF-8","cache-control":"no-cache"},timeout:5e3}).then(y).catch(P)}function y(e){return e.ok?e.text().then(b).then(E):e.text().then(g).then(w)}function b(e){try{var r;return(null!==(r=e.replace(/\r?\n|\r/g,"").match(/(.*)<\/return>/)[0])&&void 0!==r?r:"").replace("","").replace("","").split(/");return 1(.*)<\/faultstring>/)[0])&&void 0!==r?r:"").replace("","").replace("","")}catch(e){throw new Error("Não foi possível interpretar o XML de resposta.")}}function w(e){throw new Error(e)}function E(e){return{cep:e.cep,state:e.uf,city:e.cidade,neighborhood:e.bairro,street:e.end,service:"correios"}}function P(e){var r=new v({message:e.message,service:"correios"});throw"FetchError"===e.name&&(r.message="Erro ao se conectar com o serviço dos Correios."),r}function S(e){return h("".concat(1=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(!r.includes(o))throw new d({message:"Erro ao inicializar a instância do CepPromise.",type:"validation_error",errors:[{message:'O provider "'.concat(o,'" é inválido. Os providers disponíveis são: ["').concat(r.join('", "'),'"].'),service:"providers_validation"}]});return}}catch(e){n.e(e)}finally{n.f()}}(o.providers),e}).then(V).then(D).then(q).then(function(e){return r=e,t=o,n="undefined"!=typeof window?{viacep:S,widenet:A,brasilapi:F}:{correios:m,viacep:S,widenet:A,brasilapi:F},0!==t.providers.length?B.any(t.providers.map(function(e){return n[e](r)})):B.any(Object.values(n).map(function(e){return e(r)}));var r,t,n}).catch(G).catch(U)}}); \ No newline at end of file diff --git a/dist/cep-promise.js b/dist/cep-promise.js index 4c97a36..f00c3e2 100644 --- a/dist/cep-promise.js +++ b/dist/cep-promise.js @@ -311,7 +311,8 @@ headers: { 'Content-Type': 'text/xml;charset=UTF-8', 'cache-control': 'no-cache' - } + }, + timeout: 5000 }; return fetch(url, options).then(analyzeAndParseResponse)["catch"](throwApplicationError); } @@ -394,7 +395,8 @@ headers: { 'content-type': 'application/json;charset=utf-8', 'user-agent': '' - } + }, + timeout: 2000 }; return fetch(url, options).then(analyzeAndParseResponse$1).then(checkForViaCepError).then(extractCepValuesFromResponse)["catch"](throwApplicationError$1); } @@ -447,7 +449,8 @@ mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000 }; return fetch(url, options).then(analyzeAndParseResponse$2).then(checkForWideNetError).then(extractCepValuesFromResponse$1)["catch"](throwApplicationError$2); } @@ -499,7 +502,8 @@ mode: 'cors', headers: { 'content-type': 'application/json;charset=utf-8' - } + }, + timeout: 2000 }; return fetch(url, options).then(parseResponse).then(extractCepValuesFromResponse$2)["catch"](throwApplicationError$3); } diff --git a/dist/cep-promise.min.js b/dist/cep-promise.min.js index ccea9fb..2e41263 100644 --- a/dist/cep-promise.min.js +++ b/dist/cep-promise.min.js @@ -1 +1 @@ -!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("node-fetch")):"function"==typeof define&&define.amd?define(["node-fetch"],r):(e=e||self).cep=r(e.fetch)}(this,function(n){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function s(e,r,t){return(s=a()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&i(o,t.prototype),o}).apply(null,arguments)}function r(e){var n="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)})(e)}function u(e,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):r}function f(t){var n=a();return function(){var e,r=o(t);return u(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function p(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,r):void 0}}function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t\n\n \n \n \n '.concat(e,"\n \n \n"),headers:{"Content-Type":"text/xml;charset=UTF-8","cache-control":"no-cache"}};return n(r,t).then(y).catch(P)}function y(e){return e.ok?e.text().then(b).then(E):e.text().then(g).then(w)}function b(e){try{var r;return(null!==(r=e.replace(/\r?\n|\r/g,"").match(/(.*)<\/return>/)[0])&&void 0!==r?r:"").replace("","").replace("","").split(/");return 1(.*)<\/faultstring>/)[0])&&void 0!==r?r:"").replace("","").replace("","")}catch(e){throw new Error("Não foi possível interpretar o XML de resposta.")}}function w(e){throw new Error(e)}function E(e){return{cep:e.cep,state:e.uf,city:e.cidade,neighborhood:e.bairro,street:e.end,service:"correios"}}function P(e){var r=new v({message:e.message,service:"correios"});throw"FetchError"===e.name&&(r.message="Erro ao se conectar com o serviço dos Correios."),r}function j(e){var r="".concat(1=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(!r.includes(o))throw new d({message:"Erro ao inicializar a instância do CepPromise.",type:"validation_error",errors:[{message:'O provider "'.concat(o,'" é inválido. Os providers disponíveis são: ["').concat(r.join('", "'),'"].'),service:"providers_validation"}]});return}}catch(e){n.e(e)}finally{n.f()}}(o.providers),e}).then(G).then(q).then(W).then(function(e){return r=e,t=o,n="undefined"!=typeof window?{viacep:j,widenet:x,brasilapi:R}:{correios:m,viacep:j,widenet:x,brasilapi:R},0!==t.providers.length?B.any(t.providers.map(function(e){return n[e](r)})):B.any(Object.values(n).map(function(e){return e(r)}));var r,t,n}).catch(L).catch(U)}}); \ No newline at end of file +!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("node-fetch")):"function"==typeof define&&define.amd?define(["node-fetch"],r):(e=e||self).cep=r(e.fetch)}(this,function(n){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function c(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function e(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),r&&i(e,r)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,r){return(i=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function s(e,r,t){return(s=a()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&i(o,t.prototype),o}).apply(null,arguments)}function r(e){var n="function"==typeof Map?new Map:void 0;return(r=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return s(e,arguments,o(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)})(e)}function u(e,r){return!r||"object"!=typeof r&&"function"!=typeof r?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):r}function f(t){var n=a();return function(){var e,r=o(t);return u(this,n?(e=o(this).constructor,Reflect.construct(r,arguments,e)):r.apply(this,arguments))}}function p(e){return function(e){if(Array.isArray(e))return h(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,r){if(e){if("string"==typeof e)return h(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?h(e,r):void 0}}function h(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t\n\n \n \n \n '.concat(e,"\n \n \n"),headers:{"Content-Type":"text/xml;charset=UTF-8","cache-control":"no-cache"},timeout:5e3};return n(r,t).then(y).catch(P)}function y(e){return e.ok?e.text().then(b).then(E):e.text().then(g).then(w)}function b(e){try{var r;return(null!==(r=e.replace(/\r?\n|\r/g,"").match(/(.*)<\/return>/)[0])&&void 0!==r?r:"").replace("","").replace("","").split(/");return 1(.*)<\/faultstring>/)[0])&&void 0!==r?r:"").replace("","").replace("","")}catch(e){throw new Error("Não foi possível interpretar o XML de resposta.")}}function w(e){throw new Error(e)}function E(e){return{cep:e.cep,state:e.uf,city:e.cidade,neighborhood:e.bairro,street:e.end,service:"correios"}}function P(e){var r=new v({message:e.message,service:"correios"});throw"FetchError"===e.name&&(r.message="Erro ao se conectar com o serviço dos Correios."),r}function j(e){var r="".concat(1=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,c=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return a=e.done,e},e:function(e){c=!0,i=e},f:function(){try{a||null==t.return||t.return()}finally{if(c)throw i}}}}(e);try{for(n.s();!(t=n.n()).done;){var o=t.value;if(!r.includes(o))throw new d({message:"Erro ao inicializar a instância do CepPromise.",type:"validation_error",errors:[{message:'O provider "'.concat(o,'" é inválido. Os providers disponíveis são: ["').concat(r.join('", "'),'"].'),service:"providers_validation"}]});return}}catch(e){n.e(e)}finally{n.f()}}(o.providers),e}).then(G).then(q).then(W).then(function(e){return r=e,t=o,n="undefined"!=typeof window?{viacep:j,widenet:x,brasilapi:R}:{correios:m,viacep:j,widenet:x,brasilapi:R},0!==t.providers.length?B.any(t.providers.map(function(e){return n[e](r)})):B.any(Object.values(n).map(function(e){return e(r)}));var r,t,n}).catch(L).catch(U)}}); \ No newline at end of file