@rjgf/http-client
Advanced tools
Comparing version 0.2.6 to 1.0.0
@@ -89,2 +89,3 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
decompress?: boolean | undefined; | ||
transitional?: import("axios").TransitionalOptions | undefined; | ||
}; | ||
@@ -91,0 +92,0 @@ /** |
@@ -5,16 +5,17 @@ "use strict"; | ||
"use strict"; | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
_regeneratorRuntime = function _regeneratorRuntime() { | ||
return exports; | ||
}; | ||
var exports = {}, | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
Op = Object.prototype, | ||
hasOwn = Op.hasOwnProperty, | ||
defineProperty = Object.defineProperty || function (obj, key, desc) { | ||
obj[key] = desc.value; | ||
}, | ||
$Symbol = "function" == typeof Symbol ? Symbol : {}, | ||
iteratorSymbol = $Symbol.iterator || "@@iterator", | ||
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", | ||
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; | ||
function define(obj, key, value) { | ||
@@ -28,3 +29,2 @@ return Object.defineProperty(obj, key, { | ||
} | ||
try { | ||
@@ -37,50 +37,10 @@ define({}, ""); | ||
} | ||
function wrap(innerFn, outerFn, self, tryLocsList) { | ||
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return generator._invoke = function (innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
}(innerFn, self, context), generator; | ||
generator = Object.create(protoGenerator.prototype), | ||
context = new Context(tryLocsList || []); | ||
return defineProperty(generator, "_invoke", { | ||
value: makeInvokeMethod(innerFn, self, context) | ||
}), generator; | ||
} | ||
function tryCatch(fn, obj, arg) { | ||
@@ -99,12 +59,7 @@ try { | ||
} | ||
exports.wrap = wrap; | ||
var ContinueSentinel = {}; | ||
function Generator() {} | ||
function GeneratorFunction() {} | ||
function GeneratorFunctionPrototype() {} | ||
var IteratorPrototype = {}; | ||
@@ -115,6 +70,5 @@ define(IteratorPrototype, iteratorSymbol, function () { | ||
var getProto = Object.getPrototypeOf, | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype = getProto && getProto(getProto(values([]))); | ||
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); | ||
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); | ||
function defineIteratorMethods(prototype) { | ||
@@ -127,10 +81,8 @@ ["next", "throw", "return"].forEach(function (method) { | ||
} | ||
function AsyncIterator(generator, PromiseImpl) { | ||
function invoke(method, arg, resolve, reject) { | ||
var record = tryCatch(generator[method], generator, arg); | ||
if ("throw" !== record.type) { | ||
var result = record.arg, | ||
value = result.value; | ||
value = result.value; | ||
return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { | ||
@@ -146,31 +98,54 @@ invoke("next", value, resolve, reject); | ||
} | ||
reject(record.arg); | ||
} | ||
var previousPromise; | ||
this._invoke = function (method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
defineProperty(this, "_invoke", { | ||
value: function value(method, arg) { | ||
function callInvokeWithMethodAndArg() { | ||
return new PromiseImpl(function (resolve, reject) { | ||
invoke(method, arg, resolve, reject); | ||
}); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
} | ||
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); | ||
}); | ||
} | ||
function makeInvokeMethod(innerFn, self, context) { | ||
var state = "suspendedStart"; | ||
return function (method, arg) { | ||
if ("executing" === state) throw new Error("Generator is already running"); | ||
if ("completed" === state) { | ||
if ("throw" === method) throw arg; | ||
return doneResult(); | ||
} | ||
for (context.method = method, context.arg = arg;;) { | ||
var delegate = context.delegate; | ||
if (delegate) { | ||
var delegateResult = maybeInvokeDelegate(delegate, context); | ||
if (delegateResult) { | ||
if (delegateResult === ContinueSentinel) continue; | ||
return delegateResult; | ||
} | ||
} | ||
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { | ||
if ("suspendedStart" === state) throw state = "completed", context.arg; | ||
context.dispatchException(context.arg); | ||
} else "return" === context.method && context.abrupt("return", context.arg); | ||
state = "executing"; | ||
var record = tryCatch(innerFn, self, context); | ||
if ("normal" === record.type) { | ||
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; | ||
return { | ||
value: record.arg, | ||
done: context.done | ||
}; | ||
} | ||
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); | ||
} | ||
}; | ||
} | ||
function maybeInvokeDelegate(delegate, context) { | ||
var method = delegate.iterator[context.method]; | ||
if (undefined === method) { | ||
if (context.delegate = null, "throw" === context.method) { | ||
if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; | ||
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); | ||
} | ||
return ContinueSentinel; | ||
} | ||
var methodName = context.method, | ||
method = delegate.iterator[methodName]; | ||
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; | ||
var record = tryCatch(method, delegate.iterator, context.arg); | ||
@@ -181,3 +156,2 @@ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; | ||
} | ||
function pushTryEntry(locs) { | ||
@@ -189,3 +163,2 @@ var entry = { | ||
} | ||
function resetTryEntry(entry) { | ||
@@ -195,3 +168,2 @@ var record = entry.completion || {}; | ||
} | ||
function Context(tryLocsList) { | ||
@@ -202,3 +174,2 @@ this.tryEntries = [{ | ||
} | ||
function values(iterable) { | ||
@@ -209,17 +180,13 @@ if (iterable) { | ||
if ("function" == typeof iterable.next) return iterable; | ||
if (!isNaN(iterable.length)) { | ||
var i = -1, | ||
next = function next() { | ||
for (; ++i < iterable.length;) { | ||
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
} | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
next = function next() { | ||
for (; ++i < iterable.length;) { | ||
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; | ||
} | ||
return next.value = undefined, next.done = !0, next; | ||
}; | ||
return next.next = next; | ||
} | ||
} | ||
return { | ||
@@ -229,3 +196,2 @@ next: doneResult | ||
} | ||
function doneResult() { | ||
@@ -237,4 +203,9 @@ return { | ||
} | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { | ||
value: GeneratorFunctionPrototype, | ||
configurable: !0 | ||
}), defineProperty(GeneratorFunctionPrototype, "constructor", { | ||
value: GeneratorFunction, | ||
configurable: !0 | ||
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { | ||
var ctor = "function" == typeof genFun && genFun.constructor; | ||
@@ -260,9 +231,8 @@ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); | ||
return "[object Generator]"; | ||
}), exports.keys = function (object) { | ||
var keys = []; | ||
}), exports.keys = function (val) { | ||
var object = Object(val), | ||
keys = []; | ||
for (var key in object) { | ||
keys.push(key); | ||
} | ||
return keys.reverse(), function next() { | ||
@@ -273,3 +243,2 @@ for (; keys.length;) { | ||
} | ||
return next.done = !0, next; | ||
@@ -293,16 +262,12 @@ }; | ||
var context = this; | ||
function handle(loc, caught) { | ||
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; | ||
} | ||
for (var i = this.tryEntries.length - 1; i >= 0; --i) { | ||
var entry = this.tryEntries[i], | ||
record = entry.completion; | ||
record = entry.completion; | ||
if ("root" === entry.tryLoc) return handle("end"); | ||
if (entry.tryLoc <= this.prev) { | ||
var hasCatch = hasOwn.call(entry, "catchLoc"), | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
hasFinally = hasOwn.call(entry, "finallyLoc"); | ||
if (hasCatch && hasFinally) { | ||
@@ -323,3 +288,2 @@ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { | ||
@@ -330,3 +294,2 @@ var finallyEntry = entry; | ||
} | ||
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); | ||
@@ -349,6 +312,4 @@ var record = finallyEntry ? finallyEntry.completion : {}; | ||
var entry = this.tryEntries[i]; | ||
if (entry.tryLoc === tryLoc) { | ||
var record = entry.completion; | ||
if ("throw" === record.type) { | ||
@@ -358,7 +319,5 @@ var thrown = record.arg; | ||
} | ||
return thrown; | ||
} | ||
} | ||
throw new Error("illegal catch attempt"); | ||
@@ -375,3 +334,2 @@ }, | ||
} | ||
function _typeof(obj) { | ||
@@ -386,3 +344,2 @@ "@babel/helpers - typeof"; | ||
} | ||
function _classCallCheck(instance, Constructor) { | ||
@@ -393,3 +350,2 @@ if (!(instance instanceof Constructor)) { | ||
} | ||
function _defineProperties(target, props) { | ||
@@ -401,6 +357,5 @@ for (var i = 0; i < props.length; i++) { | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
@@ -414,3 +369,16 @@ if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
} | ||
function _toPropertyKey(arg) { | ||
var key = _toPrimitive(arg, "string"); | ||
return _typeof(key) === "symbol" ? key : String(key); | ||
} | ||
function _toPrimitive(input, hint) { | ||
if (_typeof(input) !== "object" || input === null) return input; | ||
var prim = input[Symbol.toPrimitive]; | ||
if (prim !== undefined) { | ||
var res = prim.call(input, hint || "default"); | ||
if (_typeof(res) !== "object") return res; | ||
throw new TypeError("@@toPrimitive must return a primitive value."); | ||
} | ||
return (hint === "string" ? String : Number)(input); | ||
} | ||
function _inherits(subClass, superClass) { | ||
@@ -420,3 +388,2 @@ if (typeof superClass !== "function" && superClass !== null) { | ||
} | ||
subClass.prototype = Object.create(superClass && superClass.prototype, { | ||
@@ -434,13 +401,9 @@ constructor: { | ||
} | ||
function _createSuper(Derived) { | ||
var hasNativeReflectConstruct = _isNativeReflectConstruct(); | ||
return function _createSuperInternal() { | ||
var Super = _getPrototypeOf(Derived), | ||
result; | ||
result; | ||
if (hasNativeReflectConstruct) { | ||
var NewTarget = _getPrototypeOf(this).constructor; | ||
result = Reflect.construct(Super, arguments, NewTarget); | ||
@@ -450,7 +413,5 @@ } else { | ||
} | ||
return _possibleConstructorReturn(this, result); | ||
}; | ||
} | ||
function _possibleConstructorReturn(self, call) { | ||
@@ -462,6 +423,4 @@ if (call && (_typeof(call) === "object" || typeof call === "function")) { | ||
} | ||
return _assertThisInitialized(self); | ||
} | ||
function _assertThisInitialized(self) { | ||
@@ -471,26 +430,18 @@ if (self === void 0) { | ||
} | ||
return self; | ||
} | ||
function _wrapNativeSuper(Class) { | ||
var _cache = typeof Map === "function" ? new Map() : undefined; | ||
_wrapNativeSuper = function _wrapNativeSuper(Class) { | ||
if (Class === null || !_isNativeFunction(Class)) return Class; | ||
if (typeof Class !== "function") { | ||
throw new TypeError("Super expression must either be null or a function"); | ||
} | ||
if (typeof _cache !== "undefined") { | ||
if (_cache.has(Class)) return _cache.get(Class); | ||
_cache.set(Class, Wrapper); | ||
} | ||
function Wrapper() { | ||
return _construct(Class, arguments, _getPrototypeOf(this).constructor); | ||
} | ||
Wrapper.prototype = Object.create(Class.prototype, { | ||
@@ -506,6 +457,4 @@ constructor: { | ||
}; | ||
return _wrapNativeSuper(Class); | ||
} | ||
function _construct(Parent, args, Class) { | ||
@@ -524,6 +473,4 @@ if (_isNativeReflectConstruct()) { | ||
} | ||
return _construct.apply(null, arguments); | ||
} | ||
function _isNativeReflectConstruct() { | ||
@@ -533,3 +480,2 @@ if (typeof Reflect === "undefined" || !Reflect.construct) return false; | ||
if (typeof Proxy === "function") return true; | ||
try { | ||
@@ -542,7 +488,5 @@ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); | ||
} | ||
function _isNativeFunction(fn) { | ||
return Function.toString.call(fn).indexOf("[native code]") !== -1; | ||
} | ||
function _setPrototypeOf(o, p) { | ||
@@ -555,3 +499,2 @@ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
} | ||
function _getPrototypeOf(o) { | ||
@@ -563,3 +506,2 @@ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { | ||
} | ||
var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) { | ||
@@ -571,3 +513,2 @@ function adopt(value) { | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
@@ -581,3 +522,2 @@ function fulfilled(value) { | ||
} | ||
function rejected(value) { | ||
@@ -590,11 +530,8 @@ try { | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = void 0 && (void 0).__importDefault || function (mod) { | ||
@@ -605,3 +542,2 @@ return mod && mod.__esModule ? mod : { | ||
}; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -611,19 +547,12 @@ value: true | ||
exports.HTTPClient = exports.HTTPError = void 0; | ||
var axios_1 = __importDefault(require("axios")); // eslint-disable-next-line import/no-named-as-default | ||
var eventemitter3_1 = __importDefault(require("eventemitter3")); // eslint-disable-next-line import/no-unused-modules | ||
var axios_1 = __importDefault(require("axios")); | ||
// eslint-disable-next-line import/no-named-as-default | ||
var eventemitter3_1 = __importDefault(require("eventemitter3")); | ||
// eslint-disable-next-line import/no-unused-modules | ||
var HTTPError = /*#__PURE__*/function (_Error) { | ||
_inherits(HTTPError, _Error); | ||
var _super = _createSuper(HTTPError); | ||
function HTTPError(message, _code, _response) { | ||
var _this; | ||
_classCallCheck(this, HTTPError); | ||
_this = _super.call(this, message); | ||
@@ -634,3 +563,2 @@ _this._code = _code; | ||
} | ||
_createClass(HTTPError, [{ | ||
@@ -647,9 +575,7 @@ key: "code", | ||
}]); | ||
return HTTPError; | ||
}( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
exports.HTTPError = HTTPError; | ||
var client = axios_1["default"].create(); // @ts-expect-error 如果是 uni-app 的话,加上对应的适配器 | ||
var client = axios_1["default"].create(); | ||
// @ts-expect-error 如果是 uni-app 的话,加上对应的适配器 | ||
if ((typeof uni === "undefined" ? "undefined" : _typeof(uni)) === 'object') { | ||
@@ -659,11 +585,8 @@ client.defaults.adapter = function (config) { | ||
return new Promise(function (resolve, reject) { | ||
var _a; // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var settle = require('axios/lib/core/settle'); // eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var buildURL = require('axios/lib/helpers/buildURL'); // @ts-expect-error ignore | ||
var _a; | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var settle = require('axios/lib/core/settle'); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var buildURL = require('axios/lib/helpers/buildURL'); | ||
// @ts-expect-error ignore | ||
uni.request({ | ||
@@ -692,16 +615,11 @@ method: (_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase(), | ||
}; | ||
} // eslint-disable-next-line import/no-unused-modules | ||
} | ||
// eslint-disable-next-line import/no-unused-modules | ||
var HTTPClient = /*#__PURE__*/function (_eventemitter3_1$defa) { | ||
_inherits(HTTPClient, _eventemitter3_1$defa); | ||
var _super2 = _createSuper(HTTPClient); // test | ||
var _super2 = _createSuper(HTTPClient); | ||
// test | ||
function HTTPClient(baseURL) { | ||
var _this2; | ||
_classCallCheck(this, HTTPClient); | ||
_this2 = _super2.call(this); | ||
@@ -720,4 +638,2 @@ _this2.client = client; | ||
*/ | ||
_createClass(HTTPClient, [{ | ||
@@ -734,3 +650,2 @@ key: "defaults", | ||
*/ | ||
}, { | ||
@@ -740,3 +655,2 @@ key: "request", | ||
var _a; | ||
return __awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { | ||
@@ -751,6 +665,4 @@ var res, response, httpError; | ||
return this.client.request(conf); | ||
case 3: | ||
res = _context.sent; | ||
if (!(conf.responseType === 'blob')) { | ||
@@ -760,5 +672,3 @@ _context.next = 6; | ||
} | ||
return _context.abrupt("return", res.data); | ||
case 6: | ||
@@ -769,8 +679,5 @@ if (!(res.data.code === 0)) { | ||
} | ||
return _context.abrupt("return", res.data); | ||
case 8: | ||
throw new HTTPError(res.data.msg, res.data.code, res); | ||
case 11: | ||
@@ -780,20 +687,14 @@ _context.prev = 11; | ||
response = _context.t0.response; | ||
if (_context.t0.message === 'Network Error') { | ||
_context.t0.message = '网络错误,请稍后重试'; | ||
} | ||
httpError = _context.t0 instanceof HTTPError ? _context.t0 : new HTTPError(((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.title) || _context.t0.message, 0, _context.t0); // 未登录的情况下就跳转登录 | ||
if (response && HTTPClient.isLoginFail(response)) { | ||
this.emit('unauthorize', httpError); | ||
} | ||
if (response && HTTPClient.isJurisdiction(response)) { | ||
this.emit('unjurisdiction', httpError); | ||
} | ||
this.emit('error', httpError); | ||
throw httpError; | ||
case 20: | ||
@@ -820,3 +721,2 @@ case "end": | ||
} | ||
return _context2.abrupt("return", this.request(Object.assign({ | ||
@@ -827,3 +727,2 @@ method: 'GET', | ||
}, config))); | ||
case 4: | ||
@@ -834,3 +733,2 @@ if (!(_args2.length === 2)) { | ||
} | ||
return _context2.abrupt("return", this.request(Object.assign({ | ||
@@ -841,3 +739,2 @@ method: 'GET', | ||
}, params))); | ||
case 8: | ||
@@ -848,3 +745,2 @@ if (!(_args2.length === 1)) { | ||
} | ||
return _context2.abrupt("return", this.request({ | ||
@@ -854,6 +750,4 @@ method: 'GET', | ||
})); | ||
case 12: | ||
return _context2.abrupt("return", Promise.reject(new Error("\u8BF7\u6C42 '".concat(url, "' \u53C2\u6570\u4E0D\u4E89\u6C14")))); | ||
case 13: | ||
@@ -880,3 +774,2 @@ case "end": | ||
} | ||
return _context3.abrupt("return", this.request(Object.assign({ | ||
@@ -887,3 +780,2 @@ method: 'POST', | ||
}, config))); | ||
case 4: | ||
@@ -894,3 +786,2 @@ if (!(_args3.length === 2)) { | ||
} | ||
return _context3.abrupt("return", this.request(Object.assign({ | ||
@@ -901,3 +792,2 @@ method: 'POST', | ||
}, Object.prototype.toString.call(body) === '[object Object]' ? body : {}))); | ||
case 8: | ||
@@ -908,3 +798,2 @@ if (!(_args3.length === 1)) { | ||
} | ||
return _context3.abrupt("return", this.request({ | ||
@@ -914,6 +803,4 @@ method: 'POST', | ||
})); | ||
case 12: | ||
return _context3.abrupt("return", Promise.reject(new Error("\u8BF7\u6C42 '".concat(url, "' \u53C2\u6570\u4E0D\u4E89\u6C14")))); | ||
case 13: | ||
@@ -940,3 +827,2 @@ case "end": | ||
} | ||
return _context4.abrupt("return", this.request(Object.assign({ | ||
@@ -947,3 +833,2 @@ method: 'PUT', | ||
}, config))); | ||
case 4: | ||
@@ -954,3 +839,2 @@ if (!(_args4.length === 2)) { | ||
} | ||
return _context4.abrupt("return", this.request(Object.assign({ | ||
@@ -961,3 +845,2 @@ method: 'PUT', | ||
}, Object.prototype.toString.call(body) === '[object Object]' ? body : {}))); | ||
case 8: | ||
@@ -968,3 +851,2 @@ if (!(_args4.length === 1)) { | ||
} | ||
return _context4.abrupt("return", this.request({ | ||
@@ -974,6 +856,4 @@ method: 'PUT', | ||
})); | ||
case 12: | ||
return _context4.abrupt("return", Promise.reject(new Error("\u8BF7\u6C42 '".concat(url, "' \u53C2\u6570\u4E0D\u4E89\u6C14")))); | ||
case 13: | ||
@@ -1002,3 +882,2 @@ case "end": | ||
} | ||
return _context5.abrupt("return", this.request(Object.assign({ | ||
@@ -1009,3 +888,2 @@ method: 'DELETE', | ||
}, config))); | ||
case 4: | ||
@@ -1016,3 +894,2 @@ if (!(_args5.length === 2)) { | ||
} | ||
return _context5.abrupt("return", this.request(Object.assign({ | ||
@@ -1023,3 +900,2 @@ method: 'DELETE', | ||
}, params))); | ||
case 8: | ||
@@ -1030,3 +906,2 @@ if (!(_args5.length === 1)) { | ||
} | ||
return _context5.abrupt("return", this.request({ | ||
@@ -1036,6 +911,4 @@ method: 'DELETE', | ||
})); | ||
case 12: | ||
return _context5.abrupt("return", Promise.reject(new Error("\u8BF7\u6C42 '".concat(url, "' \u53C2\u6570\u4E0D\u4E89\u6C14")))); | ||
case 13: | ||
@@ -1054,3 +927,2 @@ case "end": | ||
*/ | ||
}], [{ | ||
@@ -1072,3 +944,2 @@ key: "setToken", | ||
*/ | ||
}, { | ||
@@ -1080,7 +951,5 @@ key: "isJurisdiction", | ||
}]); | ||
return HTTPClient; | ||
}(eventemitter3_1["default"]); | ||
exports.HTTPClient = HTTPClient; | ||
HTTPClient.instances = []; |
@@ -23,3 +23,3 @@ { | ||
], | ||
"gitHead": "5d951b84d120e643ac59f2ee05b759e8d2c9b1ba", | ||
"gitHead": "d0dc7c3613e04ef935cfc24a885febb8aee6147c", | ||
"license": "Apache-2.0", | ||
@@ -31,9 +31,2 @@ "main": "./dist/index.js", | ||
}, | ||
"scripts": { | ||
"build": "babel dist -d dist", | ||
"dev": "yarn tsc -w", | ||
"lint": "yarn eslint --config ../../.eslintrc.js --ignore-path ../../.eslintignore --no-eslintrc --fix --ext .js,.jsx,.ts,.tsx,.vue --max-warnings 0 ./src", | ||
"prepublish": "yarn build", | ||
"test": "echo 'test skip' && exit 0" | ||
}, | ||
"babel": { | ||
@@ -44,3 +37,10 @@ "presets": [ | ||
}, | ||
"version": "0.2.6" | ||
} | ||
"version": "1.0.0", | ||
"scripts": { | ||
"build": "babel dist -d dist", | ||
"dev": "pnpm tsc -w", | ||
"lint": "pnpm eslint --config ../../.eslintrc.js --ignore-path ../../.eslintignore --no-eslintrc --fix --ext .js,.jsx,.ts,.tsx,.vue --max-warnings 0 ./src", | ||
"prepublish": "pnpm build", | ||
"test": "echo 'test skip' && exit 0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
57276
991
1