@next-core/http
Advanced tools
Comparing version 1.1.9 to 1.1.10
@@ -12,8 +12,8 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _classPrivateFieldGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldGet")); | ||
var _classPrivateMethodGet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateMethodGet")); | ||
var _classPrivateFieldSet2 = _interopRequireDefault(require("@babel/runtime/helpers/classPrivateFieldSet")); | ||
var _fetch3 = require("./fetch.js"); | ||
var _fetch2 = require("./fetch.js"); | ||
var _errors = require("./errors.js"); | ||
var _InterceptorManager = _interopRequireDefault(require("./InterceptorManager.js")); | ||
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } | ||
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } | ||
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } | ||
function isNil(value) { | ||
@@ -44,3 +44,3 @@ return value === undefined || value === null; | ||
try { | ||
response = await (0, _fetch3.fetch)(url, init); | ||
response = await (0, _fetch2.fetch)(url, init); | ||
} catch (e) { | ||
@@ -185,11 +185,8 @@ reject(isHttpAbortError(e) ? new _errors.HttpAbortError(e.toString()) : new _errors.HttpFetchError(e.toString())); | ||
var _adapter = /*#__PURE__*/new WeakMap(); | ||
var _fetch = /*#__PURE__*/new WeakSet(); | ||
var _Http_brand = /*#__PURE__*/new WeakSet(); | ||
class Http { | ||
constructor(_config) { | ||
(0, _classPrivateMethodInitSpec2.default)(this, _fetch); | ||
(0, _classPrivateMethodInitSpec2.default)(this, _Http_brand); | ||
(0, _defineProperty2.default)(this, "interceptors", void 0); | ||
(0, _classPrivateFieldInitSpec2.default)(this, _adapter, { | ||
writable: true, | ||
value: defaultAdapter | ||
}); | ||
(0, _classPrivateFieldInitSpec2.default)(this, _adapter, defaultAdapter); | ||
(0, _defineProperty2.default)(this, "request", async (url, init, options) => { | ||
@@ -201,3 +198,3 @@ const { | ||
} = init || {}; | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -213,3 +210,3 @@ data: body, | ||
(0, _defineProperty2.default)(this, "simpleRequest", (method, url, options = {}) => { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -221,3 +218,3 @@ method, | ||
(0, _defineProperty2.default)(this, "requestWithBody", (method, url, data, options = {}) => { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -234,3 +231,3 @@ method, | ||
if (_config !== null && _config !== void 0 && _config.adapter) { | ||
(0, _classPrivateFieldSet2.default)(this, _adapter, _config.adapter); | ||
_classPrivateFieldSet(_adapter, this, _config.adapter); | ||
} | ||
@@ -245,3 +242,3 @@ } | ||
get(url, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -253,3 +250,3 @@ method: "GET", | ||
delete(url, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -261,3 +258,3 @@ method: "DELETE", | ||
head(url, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -269,3 +266,3 @@ method: "HEAD", | ||
post(url, data, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -278,3 +275,3 @@ method: "POST", | ||
put(url, data, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -287,3 +284,3 @@ method: "PUT", | ||
patch(url, data, options) { | ||
return (0, _classPrivateMethodGet2.default)(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -296,3 +293,3 @@ method: "PATCH", | ||
} | ||
function _fetch2(config) { | ||
function _fetch(config) { | ||
const chain = []; | ||
@@ -303,3 +300,3 @@ let promise = Promise.resolve(config); | ||
}); | ||
chain.push(config => (0, _classPrivateFieldGet2.default)(this, _adapter).call(this, config), undefined); | ||
chain.push(config => _classPrivateFieldGet(_adapter, this).call(this, config), undefined); | ||
this.interceptors.response.forEach(interceptor => { | ||
@@ -306,0 +303,0 @@ chain.push(res => { |
import _classPrivateMethodInitSpec from "@babel/runtime/helpers/classPrivateMethodInitSpec"; | ||
import _classPrivateFieldInitSpec from "@babel/runtime/helpers/classPrivateFieldInitSpec"; | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _classPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet"; | ||
import _classPrivateMethodGet from "@babel/runtime/helpers/classPrivateMethodGet"; | ||
import _classPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet"; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread2"; | ||
@@ -13,2 +10,5 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
_excluded3 = ["body", "method"]; | ||
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } | ||
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } | ||
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } | ||
import { fetch } from "./fetch.js"; | ||
@@ -189,12 +189,9 @@ import { HttpAbortError, HttpFetchError, HttpParseError, HttpResponseError } from "./errors.js"; | ||
var _adapter = /*#__PURE__*/new WeakMap(); | ||
var _fetch = /*#__PURE__*/new WeakSet(); | ||
var _Http_brand = /*#__PURE__*/new WeakSet(); | ||
class Http { | ||
constructor(_config) { | ||
var _this = this; | ||
_classPrivateMethodInitSpec(this, _fetch); | ||
_classPrivateMethodInitSpec(this, _Http_brand); | ||
_defineProperty(this, "interceptors", void 0); | ||
_classPrivateFieldInitSpec(this, _adapter, { | ||
writable: true, | ||
value: defaultAdapter | ||
}); | ||
_classPrivateFieldInitSpec(this, _adapter, defaultAdapter); | ||
_defineProperty(this, "request", /*#__PURE__*/function () { | ||
@@ -208,3 +205,3 @@ var _ref6 = _asyncToGenerator(function* (url, init, options) { | ||
requestInit = _objectWithoutProperties(_ref7, _excluded3); | ||
return _classPrivateMethodGet(_this, _fetch, _fetch2).call(_this, { | ||
return _assertClassBrand(_Http_brand, _this, _fetch).call(_this, { | ||
url, | ||
@@ -222,3 +219,3 @@ data: body, | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return _classPrivateMethodGet(_this, _fetch, _fetch2).call(_this, { | ||
return _assertClassBrand(_Http_brand, _this, _fetch).call(_this, { | ||
url, | ||
@@ -231,3 +228,3 @@ method, | ||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; | ||
return _classPrivateMethodGet(_this, _fetch, _fetch2).call(_this, { | ||
return _assertClassBrand(_Http_brand, _this, _fetch).call(_this, { | ||
url, | ||
@@ -244,3 +241,3 @@ method, | ||
if (_config !== null && _config !== void 0 && _config.adapter) { | ||
_classPrivateFieldSet(this, _adapter, _config.adapter); | ||
_classPrivateFieldSet(_adapter, this, _config.adapter); | ||
} | ||
@@ -255,3 +252,3 @@ } | ||
get(url, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -263,3 +260,3 @@ method: "GET", | ||
delete(url, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -271,3 +268,3 @@ method: "DELETE", | ||
head(url, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -279,3 +276,3 @@ method: "HEAD", | ||
post(url, data, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -288,3 +285,3 @@ method: "POST", | ||
put(url, data, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -297,3 +294,3 @@ method: "PUT", | ||
patch(url, data, options) { | ||
return _classPrivateMethodGet(this, _fetch, _fetch2).call(this, { | ||
return _assertClassBrand(_Http_brand, this, _fetch).call(this, { | ||
url, | ||
@@ -306,3 +303,3 @@ method: "PATCH", | ||
} | ||
function _fetch2(config) { | ||
function _fetch(config) { | ||
var chain = []; | ||
@@ -313,3 +310,3 @@ var promise = Promise.resolve(config); | ||
}); | ||
chain.push(config => _classPrivateFieldGet(this, _adapter).call(this, config), undefined); | ||
chain.push(config => _classPrivateFieldGet(_adapter, this).call(this, config), undefined); | ||
this.interceptors.response.forEach(interceptor => { | ||
@@ -316,0 +313,0 @@ chain.push(res => { |
{ | ||
"name": "@next-core/http", | ||
"version": "1.1.9", | ||
"version": "1.1.10", | ||
"description": "> TODO: description", | ||
@@ -41,7 +41,7 @@ "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/http", | ||
"devDependencies": { | ||
"@next-core/build-next-libs": "^1.0.12", | ||
"@next-core/test-next": "^1.0.15", | ||
"@next-core/build-next-libs": "^1.0.13", | ||
"@next-core/test-next": "^1.0.16", | ||
"whatwg-fetch": "^3.6.20" | ||
}, | ||
"gitHead": "d5dca39967b733d58d60840cafccc0c02f80aba5" | ||
"gitHead": "7794348c3503d686fbdd8595be9c51191aa2de5d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
96978
1040