🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

complex-require

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

complex-require - npm Package Compare versions

Comparing version
3.2.5
to
3.2.6
+1
-1
package.json
{
"name": "complex-require",
"version": "3.2.5",
"version": "3.2.6",
"description": "a complex require",

@@ -5,0 +5,0 @@ "main": "index.ts",

@@ -22,4 +22,6 @@ import { AxiosRequestConfig } from 'axios'

$fail?: boolean | failType // 错误回调
$format?: (options: InstanceInitOption, isRefresh?: boolean) => InstanceInitOption
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface InstanceInitOption<D = any> extends AxiosRequestConfig<D>, customParameters {

@@ -43,2 +45,3 @@ url: string

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
appendData(location: locationType, prop: string, data: any) {

@@ -82,2 +85,5 @@ if (location === 'body') {

}
if (this.data.$format) {
this.data.$format(this.data, isRefresh)
}
}

@@ -84,0 +90,0 @@ restoreData() {

@@ -22,2 +22,3 @@ import axios, { AxiosInstance, AxiosRequestConfig } from 'axios'

instance: Instance
// eslint-disable-next-line @typescript-eslint/no-explicit-any
error: any

@@ -37,3 +38,3 @@ }

const defaultFormatUrlWithBaseUrl = function(this: Require, url: string) {
if (url.indexOf('https://') != 0 && url.indexOf('http://') != 0) {
if (url.indexOf('https://') !== 0 && url.indexOf('http://') !== 0) {
// 当前URL不以http/https开始,则认为此URL需要添加默认前缀

@@ -78,3 +79,3 @@ url = this.baseUrl + url

}
if (getEnv('real') == 'development' && config.require.showRule) {
if (getEnv('real') === 'development' && config.require.showRule) {
this.$exportMsg(`默认的请求处理规则为[${this.rule.default!.$selfName()}]`, 'log')

@@ -155,3 +156,3 @@ }

require(requireOption: requireOptionType, defaultRequireOption?: defaultRequireOptionType) {
if (getType(requireOption) != 'object') {
if (getType(requireOption) !== 'object') {
return Promise.reject({ status: 'fail', code: 'undefined optionData', msg: '未定义请求数据!' })

@@ -170,2 +171,3 @@ } else {

}).catch(err => {
// eslint-disable-next-line no-console
console.error(err)

@@ -175,2 +177,3 @@ reject(err)

}).catch(err => {
// eslint-disable-next-line no-console
console.error(err)

@@ -185,3 +188,3 @@ instance.fail(true, err.msg, 'error')

this.ajax(instance.data).then(response => {
if (instance.data.responseType === undefined || instance.data.responseType == 'json') {
if (instance.data.responseType === undefined || instance.data.responseType === 'json') {
if (instance.data.$responseFormat) {

@@ -240,2 +243,3 @@ const responseData = ruleItem.format(response, instance)

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
$formatError (error: any, instance: Instance, ruleItem: Rule) {

@@ -289,2 +293,3 @@ const errRes: errorType = {

}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setToken (tokenName: string, data: any, prop = 'default', noSave?: boolean) {

@@ -291,0 +296,0 @@ if (this.rule[prop]) {