|
4 | 4 | (global.cep = factory()); |
5 | 5 | }(this, (function () { 'use strict'; |
6 | 6 |
|
7 | | -function CepPromiseError() { |
8 | | - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
9 | | - message = _ref.message, |
10 | | - type = _ref.type, |
11 | | - errors = _ref.errors; |
| 7 | +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
| 8 | + return typeof obj; |
| 9 | +} : function (obj) { |
| 10 | + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
| 11 | +}; |
12 | 12 |
|
13 | | - this.name = 'CepPromiseError'; |
14 | | - this.message = message; |
15 | | - this.type = type; |
16 | | - this.errors = errors; |
17 | | -} |
| 13 | +var classCallCheck = function (instance, Constructor) { |
| 14 | + if (!(instance instanceof Constructor)) { |
| 15 | + throw new TypeError("Cannot call a class as a function"); |
| 16 | + } |
| 17 | +}; |
| 18 | + |
| 19 | +var inherits = function (subClass, superClass) { |
| 20 | + if (typeof superClass !== "function" && superClass !== null) { |
| 21 | + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); |
| 22 | + } |
18 | 23 |
|
19 | | -CepPromiseError.prototype = new Error(); |
| 24 | + subClass.prototype = Object.create(superClass && superClass.prototype, { |
| 25 | + constructor: { |
| 26 | + value: subClass, |
| 27 | + enumerable: false, |
| 28 | + writable: true, |
| 29 | + configurable: true |
| 30 | + } |
| 31 | + }); |
| 32 | + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; |
| 33 | +}; |
| 34 | + |
| 35 | +var possibleConstructorReturn = function (self, call) { |
| 36 | + if (!self) { |
| 37 | + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
| 38 | + } |
| 39 | + |
| 40 | + return call && (typeof call === "object" || typeof call === "function") ? call : self; |
| 41 | +}; |
| 42 | + |
| 43 | +var toConsumableArray = function (arr) { |
| 44 | + if (Array.isArray(arr)) { |
| 45 | + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; |
| 46 | + |
| 47 | + return arr2; |
| 48 | + } else { |
| 49 | + return Array.from(arr); |
| 50 | + } |
| 51 | +}; |
| 52 | + |
| 53 | +var CepPromiseError = function (_Error) { |
| 54 | + inherits(CepPromiseError, _Error); |
| 55 | + |
| 56 | + function CepPromiseError() { |
| 57 | + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
| 58 | + message = _ref.message, |
| 59 | + type = _ref.type, |
| 60 | + errors = _ref.errors; |
| 61 | + |
| 62 | + classCallCheck(this, CepPromiseError); |
| 63 | + |
| 64 | + var _this = possibleConstructorReturn(this, (CepPromiseError.__proto__ || Object.getPrototypeOf(CepPromiseError)).call(this)); |
| 65 | + |
| 66 | + _this.name = 'CepPromiseError'; |
| 67 | + _this.message = message; |
| 68 | + _this.type = type; |
| 69 | + _this.errors = errors; |
| 70 | + return _this; |
| 71 | + } |
| 72 | + |
| 73 | + return CepPromiseError; |
| 74 | +}(Error); |
20 | 75 |
|
21 | 76 | var index = typeof fetch == 'function' ? fetch.bind() : function (url, options) { |
22 | 77 | options = options || {}; |
@@ -95,17 +150,26 @@ var require$$0 = ( unfetch_es && index ) || unfetch_es; |
95 | 150 |
|
96 | 151 | var browser = window.fetch || (window.fetch = require$$0.default || require$$0); |
97 | 152 |
|
98 | | -function ServiceError() { |
99 | | - var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
100 | | - message = _ref.message, |
101 | | - service = _ref.service; |
| 153 | +var ServiceError = function (_Error) { |
| 154 | + inherits(ServiceError, _Error); |
102 | 155 |
|
103 | | - this.name = 'ServiceError'; |
104 | | - this.message = message; |
105 | | - this.service = service; |
106 | | -} |
| 156 | + function ServiceError() { |
| 157 | + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
| 158 | + message = _ref.message, |
| 159 | + service = _ref.service; |
| 160 | + |
| 161 | + classCallCheck(this, ServiceError); |
107 | 162 |
|
108 | | -ServiceError.prototype = new Error(); |
| 163 | + var _this = possibleConstructorReturn(this, (ServiceError.__proto__ || Object.getPrototypeOf(ServiceError)).call(this)); |
| 164 | + |
| 165 | + _this.name = 'ServiceError'; |
| 166 | + _this.message = message; |
| 167 | + _this.service = service; |
| 168 | + return _this; |
| 169 | + } |
| 170 | + |
| 171 | + return ServiceError; |
| 172 | +}(Error); |
109 | 173 |
|
110 | 174 | var PROXY_URL = 'https://proxier.now.sh/'; |
111 | 175 | var CEP_ABERTO_TOKEN = '37d718d2984e6452584a76d3d59d3a26'; |
@@ -305,22 +369,6 @@ var CepAbertoService = typeof process === 'undefined' ? injectProxy(fetchCepAber |
305 | 369 | var CorreiosService = typeof process === 'undefined' ? injectProxy(fetchCorreiosService) : fetchCorreiosService; |
306 | 370 | var ViaCepService = fetchViaCepService; |
307 | 371 |
|
308 | | -var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { |
309 | | - return typeof obj; |
310 | | -} : function (obj) { |
311 | | - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; |
312 | | -}; |
313 | | - |
314 | | -var toConsumableArray = function (arr) { |
315 | | - if (Array.isArray(arr)) { |
316 | | - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; |
317 | | - |
318 | | - return arr2; |
319 | | - } else { |
320 | | - return Array.from(arr); |
321 | | - } |
322 | | -}; |
323 | | - |
324 | 372 | var reverse = function reverse(promise) { |
325 | 373 | return new Promise(function (resolve, reject) { |
326 | 374 | return Promise.resolve(promise).then(reject, resolve); |
|
0 commit comments