From ec1587111aa263c3a18259ca6fad34d72a3beb42 Mon Sep 17 00:00:00 2001 From: early-autumn <954270063@qq.com> Date: Wed, 22 Jul 2020 14:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/axios-miniprogram.iml | 9 ++++ .idea/dictionaries/fluff.xml | 7 +++ .idea/google-java-format.xml | 6 +++ .idea/inspectionProfiles/Project_Default.xml | 6 +++ .idea/misc.xml | 9 ++++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 +++ README.md | 16 +++--- package.json | 52 ++++++++++---------- src/adaptive.ts | 10 +--- src/axios.ts | 6 --- src/cancel/Cancel.ts | 8 +-- src/cancel/CancelToken.ts | 6 --- src/cancel/isCancel.ts | 8 +-- src/core/Axios.ts | 6 --- src/core/InterceptorManager.ts | 8 +-- src/core/createError.ts | 6 --- src/core/dispatchRequest.ts | 6 --- src/core/flattenHeaders.ts | 6 --- src/core/mergeConfig.ts | 6 --- src/core/request.ts | 6 --- src/core/transformData.ts | 12 ++--- src/core/transformMethod.ts | 6 --- src/core/transformRequest.ts | 6 --- src/core/transformResponse.ts | 6 --- src/defaults.ts | 6 --- src/helpers/buildURL.ts | 8 +-- src/helpers/combineURL.ts | 7 --- src/helpers/isAbsoluteURL.ts | 7 --- src/helpers/utils.ts | 10 +--- src/index.ts | 6 --- src/types.ts | 7 --- test/adaptive.test.ts | 6 --- test/axios.test.ts | 6 --- test/cancel/Cancel.test.ts | 6 --- test/cancel/CancelToken.test.ts | 8 +-- test/cancel/isCancel.test.ts | 6 --- test/core/Axios.test.ts | 10 +--- test/core/InterceptorManager.test.ts | 6 --- test/core/dispatchRequest.test.ts | 6 --- test/core/flattenHeaders.test.ts | 6 --- test/core/mergeConfig.test.ts | 6 --- test/core/request.test.ts | 6 --- test/core/transformData.test.ts | 6 --- test/core/transformMethod.test.ts | 6 --- test/core/transformRequest.test.ts | 6 --- test/core/transformResponse.test.ts | 6 --- test/helpers/buildURL.test.ts | 6 --- test/helpers/combineURL.test.ts | 6 --- test/helpers/isAbsoluteURL.test.ts | 6 --- test/helpers/utils.test.ts | 6 --- 52 files changed, 107 insertions(+), 303 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/axios-miniprogram.iml create mode 100644 .idea/dictionaries/fluff.xml create mode 100644 .idea/google-java-format.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/axios-miniprogram.iml b/.idea/axios-miniprogram.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/axios-miniprogram.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/dictionaries/fluff.xml b/.idea/dictionaries/fluff.xml new file mode 100644 index 0000000..883278d --- /dev/null +++ b/.idea/dictionaries/fluff.xml @@ -0,0 +1,7 @@ + + + + axios + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..2aa056d --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..03d9549 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..fff67ee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..be0275a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 5cc3270..8892a6f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # axios-miniprogram -[![build status](https://travis-ci.com/early-autumn/axios-miniprogram.svg?branch=master)](https://travis-ci.org/early-autumn/axios-miniprogram) -[![Coverage Status](https://coveralls.io/repos/github/early-autumn/axios-miniprogram/badge.svg?branch=master)](https://coveralls.io/github/early-autumn/axios-miniprogram?branch=master) +[![build status](https://travis-ci.com/zjx0905/axios-miniprogram.svg?branch=master)](https://travis-ci.org/zjx0905/axios-miniprogram) +[![Coverage Status](https://coveralls.io/repos/github/zjx0905/axios-miniprogram/badge.svg?branch=master)](https://coveralls.io/github/zjx0905/axios-miniprogram?branch=master) [![npm version](https://badge.fury.io/js/axios-miniprogram.svg)](https://badge.fury.io/js/axios-miniprogram) [![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT) @@ -486,18 +486,18 @@ instance.get('/test'); `axios.Axios`是一个类,其实`axios`就是`axios.Axios`类的实例改造而来的,`axios.create(defaults)`创建的也是`axios.Axios`的实例。 -直接实例化`axios.Axios`可以得到一个`纯净的实例`,不能当函数调用,传入的自定义配置就是`纯净的实例`的默认配置,而不会像`axios.create(defaults)`一样去合并`axios`中的默认配置。 +直接实例化`axios.Axios`可以得到一个`原始实例`,不能当函数调用,传入的自定义配置就是`原始实例`的默认配置,而不会像`axios.create(defaults)`一样去合并`axios`中的默认配置。 ```typescript axios.defaults.baseURL = 'https://www.xxx.com'; const instance = new axios.Axios({ - params: { value: '零污染' } + params: { value: 123 } }); -// 最终请求的 URL 是这样的 => /test?value=零污染 +// 最终请求的 URL 是这样的 => /test?value=123 // /test 来自传入的 '/test' -// value=零污染 来自 instance.defaults.params +// value=123 来自 instance.defaults.params instance.get('/test'); ``` @@ -512,7 +512,3 @@ axios('/test').then().catch(); // 请求失败 // axios => axios.interceptors.request => config.transformRequest => config.paramsSerializer => config.adapter => config.validateStatus => config.transformResponse => config.errorHandler => axios.interceptors.response => catch ``` - -## Typescript - -![avatar](http://chuantu.xyz/t6/730/1587543726x1700338641.jpg) \ No newline at end of file diff --git a/package.json b/package.json index 81b979a..005ea81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "axios-miniprogram", - "version": "1.1.2", + "version": "1.1.3", "description": "基于 Promise 的 HTTP 请求库,适用于各大小程序平台。", "main": "package/index.js", "miniprogram": "package", @@ -33,7 +33,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/early-autumn/axios-miniprogram.git" + "url": "git+https://github.com/zjx0905/axios-miniprogram.git" }, "keywords": [ "axios", @@ -41,34 +41,34 @@ "request", "promise" ], - "author": "early-autumn", + "author": "zjx0905", "license": "MIT", "bugs": { - "url": "https://github.com/early-autumn/axios-miniprogram/issues" + "url": "https://github.com/zjx0905/axios-miniprogram/issues" }, - "homepage": "https://github.com/early-autumn/axios-miniprogram#readme", + "homepage": "https://github.com/zjx0905/axios-miniprogram#readme", "devDependencies": { - "@babel/core": "^7.8.7", - "@babel/plugin-proposal-optional-chaining": "^7.8.3", - "@babel/plugin-transform-modules-commonjs": "^7.9.0", - "@babel/plugin-transform-runtime": "^7.8.3", - "@babel/preset-env": "^7.8.7", - "@babel/preset-typescript": "^7.8.3", - "@babel/runtime": "^7.8.7", - "@types/jest": "^25.1.3", - "@typescript-eslint/eslint-plugin": "^2.22.0", - "@typescript-eslint/parser": "^2.22.0", - "coveralls": "^3.0.9", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.10.0", - "eslint-plugin-prettier": "^3.1.2", - "husky": "^4.2.3", - "jest": "^25.1.0", - "prettier": "^1.19.1", + "@babel/core": "^7.10.5", + "@babel/plugin-proposal-optional-chaining": "^7.10.4", + "@babel/plugin-transform-modules-commonjs": "^7.10.4", + "@babel/plugin-transform-runtime": "^7.10.5", + "@babel/preset-env": "^7.10.4", + "@babel/preset-typescript": "^7.10.4", + "@babel/runtime": "^7.10.5", + "@types/jest": "^26.0.5", + "@typescript-eslint/eslint-plugin": "^3.7.0", + "@typescript-eslint/parser": "^3.7.0", + "coveralls": "^3.1.0", + "eslint": "^7.5.0", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-prettier": "^3.1.4", + "husky": "^4.2.5", + "jest": "^26.1.0", + "prettier": "^2.0.5", "rollup-plugin-babel": "^4.4.0", "rollup-plugin-node-resolve": "^5.2.0", - "rollup-plugin-typescript2": "^0.26.0", - "ts-jest": "^25.2.1", - "typescript": "^3.8.3" + "rollup-plugin-typescript2": "^0.27.1", + "ts-jest": "^26.1.3", + "typescript": "^3.9.7" } -} \ No newline at end of file +} diff --git a/src/adaptive.ts b/src/adaptive.ts index 6a8b7f4..91b5c2a 100644 --- a/src/adaptive.ts +++ b/src/adaptive.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-17 12:18:25 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 19:10:04 - */ import { Adapter, Platform } from './types'; // uniapp @@ -23,7 +17,7 @@ declare let qq: Platform; * 自适应当前平台 */ export default function adaptive(): Adapter | undefined { - const stack = [ + const stack: (() => Adapter)[] = [ () => uni.request, () => wx.request, () => my.request, @@ -36,7 +30,7 @@ export default function adaptive(): Adapter | undefined { while (stack.length !== 0 && adapter === undefined) { try { - adapter = (stack.shift() as Function)(); + adapter = (stack.shift() as () => Adapter)(); } catch (err) {} } diff --git a/src/axios.ts b/src/axios.ts index a78e701..09047d5 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-15 12:45:18 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-24 09:26:03 - */ import { AxiosRequestConfig, Data, AxiosResponse, AxiosBaseInstance, AxiosInstance } from './types'; import Axios from './core/Axios'; import mergeConfig from './core/mergeConfig'; diff --git a/src/cancel/Cancel.ts b/src/cancel/Cancel.ts index 0353a1a..25cdbfc 100644 --- a/src/cancel/Cancel.ts +++ b/src/cancel/Cancel.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 21:14:53 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 09:26:10 - */ import { Cancel } from '../types'; export default class CancelClass implements Cancel { @@ -12,7 +6,7 @@ export default class CancelClass implements Cancel { */ public constructor(public message?: string) {} - public toString() { + public toString(): string { const message = this.message ? `: ${this.message}` : ''; return `Cancel${message}`; diff --git a/src/cancel/CancelToken.ts b/src/cancel/CancelToken.ts index b2db8a9..ae9bccb 100644 --- a/src/cancel/CancelToken.ts +++ b/src/cancel/CancelToken.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 20:00:08 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-05 08:52:21 - */ import { CancelToken, CancelAction, CancelExecutor, CancelTokenSource } from '../types'; import Cancel from './Cancel'; diff --git a/src/cancel/isCancel.ts b/src/cancel/isCancel.ts index fcde5ce..b9d8c96 100644 --- a/src/cancel/isCancel.ts +++ b/src/cancel/isCancel.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-14 09:23:25 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-23 22:44:43 - */ import Cancel from './Cancel'; /** @@ -11,6 +5,6 @@ import Cancel from './Cancel'; * * @param value 判断的值 */ -export default function isCancel(value: any): value is Cancel { +export default function isCancel(value: unknown): value is Cancel { return value instanceof Cancel; } diff --git a/src/core/Axios.ts b/src/core/Axios.ts index 7832413..b897546 100644 --- a/src/core/Axios.ts +++ b/src/core/Axios.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 18:00:27 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-05 08:58:47 - */ import { Method, Params, Data, Interceptors, AxiosRequestConfig, AxiosResponse, Axios } from '../types'; import buildURL from '../helpers/buildURL'; import mergeConfig from './mergeConfig'; diff --git a/src/core/InterceptorManager.ts b/src/core/InterceptorManager.ts index ec82b36..1f84469 100644 --- a/src/core/InterceptorManager.ts +++ b/src/core/InterceptorManager.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-15 17:50:50 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-05 09:01:50 - */ import { InterceptorResolved, InterceptorRejected, @@ -26,7 +20,7 @@ export default class InterceptorManagerClass implements InterceptorManager */ private _interceptors: Record> = {}; - public use(resolved: InterceptorResolved, rejected?: InterceptorRejected) { + public use(resolved: InterceptorResolved, rejected?: InterceptorRejected): number { this._interceptors[++this._id] = { resolved, rejected, diff --git a/src/core/createError.ts b/src/core/createError.ts index 7f48958..6bb3ec3 100644 --- a/src/core/createError.ts +++ b/src/core/createError.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-14 22:23:39 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-02 17:41:55 - */ import { AxiosRequestConfig, RequestConfig, AxiosResponse, AxiosError } from '../types'; /** diff --git a/src/core/dispatchRequest.ts b/src/core/dispatchRequest.ts index 9636519..561b7d8 100644 --- a/src/core/dispatchRequest.ts +++ b/src/core/dispatchRequest.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 18:01:16 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 09:24:20 - */ import { AxiosRequestConfig, AxiosResponse } from '../types'; import isCancel from '../cancel/isCancel'; import flattenHeaders from './flattenHeaders'; diff --git a/src/core/flattenHeaders.ts b/src/core/flattenHeaders.ts index fcdb0b2..134b60d 100644 --- a/src/core/flattenHeaders.ts +++ b/src/core/flattenHeaders.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-18 12:00:01 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 13:44:26 - */ import { Headers, AxiosRequestConfig } from '../types'; import { omit } from '../helpers/utils'; import { methodToLowercase } from './transformMethod'; diff --git a/src/core/mergeConfig.ts b/src/core/mergeConfig.ts index 057de08..fb50348 100644 --- a/src/core/mergeConfig.ts +++ b/src/core/mergeConfig.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-15 22:48:25 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-23 23:55:19 - */ import { AnyObject, AxiosRequestConfig } from '../types'; import { isPlainObject, deepMerge } from '../helpers/utils'; diff --git a/src/core/request.ts b/src/core/request.ts index 6ec22b0..5878eee 100644 --- a/src/core/request.ts +++ b/src/core/request.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-16 00:48:45 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-02 14:33:49 - */ import { AxiosRequestConfig, AxiosResponse, Response } from '../types'; import transformRequest from './transformRequest'; import transformResponse from './transformResponse'; diff --git a/src/core/transformData.ts b/src/core/transformData.ts index 38a3e49..9fda6d9 100644 --- a/src/core/transformData.ts +++ b/src/core/transformData.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-16 22:37:44 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 09:30:42 - */ import { Data, Headers, TransformData } from '../types'; /** @@ -13,7 +7,11 @@ import { Data, Headers, TransformData } from '../types'; * @param headers 请求头/响应头 * @param transforms 请求数据转换函数/响应数据转换函数 */ -export default function transformData(data: Data, headers: Headers, transforms?: TransformData | TransformData[]) { +export default function transformData( + data: Data, + headers: Headers, + transforms?: TransformData | TransformData[] +): Data { if (transforms === undefined) { return data; } diff --git a/src/core/transformMethod.ts b/src/core/transformMethod.ts index 6728a5c..2ca0076 100644 --- a/src/core/transformMethod.ts +++ b/src/core/transformMethod.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 13:31:45 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 13:45:11 - */ import { AliasMethod, AdapterMethod, Method } from '../types'; /** diff --git a/src/core/transformRequest.ts b/src/core/transformRequest.ts index 4219c7d..ee24b38 100644 --- a/src/core/transformRequest.ts +++ b/src/core/transformRequest.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-17 15:05:43 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 09:27:30 - */ import { AxiosRequestConfig, RequestConfig } from '../types'; import { pick } from '../helpers/utils'; import isAbsoluteURL from '../helpers/isAbsoluteURL'; diff --git a/src/core/transformResponse.ts b/src/core/transformResponse.ts index 32d02c2..90c9208 100644 --- a/src/core/transformResponse.ts +++ b/src/core/transformResponse.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-17 14:09:16 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-25 09:29:50 - */ import { AxiosRequestConfig, AxiosResponse, Response } from '../types'; import { pick } from '../helpers/utils'; diff --git a/src/defaults.ts b/src/defaults.ts index 5ca6a29..6263842 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-15 22:09:38 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-23 09:11:41 - */ import { AxiosRequestConfig } from './types'; import adaptive from './adaptive'; diff --git a/src/helpers/buildURL.ts b/src/helpers/buildURL.ts index 74d934f..56468ad 100644 --- a/src/helpers/buildURL.ts +++ b/src/helpers/buildURL.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 21:45:45 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-22 15:51:28 - */ import { AnyObject, Params } from '../types'; import { encode, isPlainObject, isDate } from './utils'; @@ -73,7 +67,7 @@ function paramsSerialization(params: AnyObject): string { * * @param url 请求地址 * @param params 请求参数 - * @param paramsSerialized 自定义参数序列化 + * @param paramsSerializer 自定义参数序列化 */ export default function buildURL(url: string, params: Params = {}, paramsSerializer = paramsSerialization): string { return generateURL(url, paramsSerializer(params)); diff --git a/src/helpers/combineURL.ts b/src/helpers/combineURL.ts index da92245..aeac200 100644 --- a/src/helpers/combineURL.ts +++ b/src/helpers/combineURL.ts @@ -1,10 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 09:16:47 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 09:19:23 - */ - /** * 拼接 baseURL 和 url 获得完整的 URL * diff --git a/src/helpers/isAbsoluteURL.ts b/src/helpers/isAbsoluteURL.ts index efa37ec..25bbfa8 100644 --- a/src/helpers/isAbsoluteURL.ts +++ b/src/helpers/isAbsoluteURL.ts @@ -1,10 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 09:17:40 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 09:19:11 - */ - /** * 检查是否是一个绝对 URL * diff --git a/src/helpers/utils.ts b/src/helpers/utils.ts index 1f7e6b4..8dd9a18 100644 --- a/src/helpers/utils.ts +++ b/src/helpers/utils.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 21:55:40 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-23 22:38:30 - */ import { AnyObject } from '../types'; const _toString = Object.prototype.toString; @@ -29,7 +23,7 @@ export function encode(str: string): string { * * @param date 判断目标 */ -export function isDate(date: any): date is Date { +export function isDate(date: unknown): date is Date { return _toString.call(date) === '[object Date]'; } @@ -38,7 +32,7 @@ export function isDate(date: any): date is Date { * * @param obj 判断目标 */ -export function isPlainObject(obj: any): obj is object { +export function isPlainObject(obj: unknown): obj is Record { return _toString.call(obj) === '[object Object]'; } diff --git a/src/index.ts b/src/index.ts index 721d65b..e1c35dc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-14 23:22:52 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-02 22:44:34 - */ import axios from './axios'; export * from './types'; diff --git a/src/types.ts b/src/types.ts index d1718d2..24d376f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,10 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-13 15:23:53 - * @LastEditors: early-autumn - * @LastEditTime: 2020-05-05 09:02:12 - */ - /** * 任意值对象 */ diff --git a/test/adaptive.test.ts b/test/adaptive.test.ts index f322980..d3ef01f 100644 --- a/test/adaptive.test.ts +++ b/test/adaptive.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 17:22:26 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 22:20:47 - */ import adaptive from '../src/adaptive'; declare global { diff --git a/test/axios.test.ts b/test/axios.test.ts index da3b52b..2c30b1c 100644 --- a/test/axios.test.ts +++ b/test/axios.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 13:58:00 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 09:33:06 - */ import axios from '../src/axios'; describe('测试 src/axios.ts', () => { diff --git a/test/cancel/Cancel.test.ts b/test/cancel/Cancel.test.ts index ca0f07c..53ad302 100644 --- a/test/cancel/Cancel.test.ts +++ b/test/cancel/Cancel.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 15:09:33 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 15:17:27 - */ import Cancel from '../../src/cancel/Cancel'; describe('测试 src/cancel/Cancel.ts', () => { diff --git a/test/cancel/CancelToken.test.ts b/test/cancel/CancelToken.test.ts index 8b0f5e6..ed3a01a 100644 --- a/test/cancel/CancelToken.test.ts +++ b/test/cancel/CancelToken.test.ts @@ -1,14 +1,8 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 15:17:50 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 09:01:02 - */ import CancelToken from '../../src/cancel/CancelToken'; describe('测试 src/cancel/CancelToken.ts', () => { it('实例化', () => { - const token = new CancelToken(function(cancel) { + const token = new CancelToken(function (cancel) { cancel('取消'); }); diff --git a/test/cancel/isCancel.test.ts b/test/cancel/isCancel.test.ts index 03c5e83..f67c99e 100644 --- a/test/cancel/isCancel.test.ts +++ b/test/cancel/isCancel.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 15:12:17 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 08:57:38 - */ import isCancel from '../../src/cancel/isCancel'; import Cancel from '../../src/cancel/Cancel'; diff --git a/test/core/Axios.test.ts b/test/core/Axios.test.ts index c8d654d..bc8d368 100644 --- a/test/core/Axios.test.ts +++ b/test/core/Axios.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 20:47:09 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-22 16:04:16 - */ import Axios from '../../src/core/Axios'; const instance = new Axios(); @@ -29,12 +23,12 @@ describe('测试 src/core/Axios.ts', () => { return 'task'; }; - instance.interceptors.request.use(function(config) { + instance.interceptors.request.use(function (config) { config.data = 'interceptors_request'; return config; }); - instance.interceptors.response.use(function(response) { + instance.interceptors.response.use(function (response) { response.data = 'interceptors_response'; return response; }); diff --git a/test/core/InterceptorManager.test.ts b/test/core/InterceptorManager.test.ts index 923396d..e674237 100644 --- a/test/core/InterceptorManager.test.ts +++ b/test/core/InterceptorManager.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 15:40:44 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-23 09:29:17 - */ import InterceptorManager from '../../src/core/InterceptorManager'; describe('测试 src/core/InterceptorManager.ts', () => { diff --git a/test/core/dispatchRequest.test.ts b/test/core/dispatchRequest.test.ts index bdc2ce0..a72efa5 100644 --- a/test/core/dispatchRequest.test.ts +++ b/test/core/dispatchRequest.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 22:42:46 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 19:38:53 - */ import { CancelAction } from '../../src/types'; import dispatchRequest from '../../src/core/dispatchRequest'; import CancelToken from '../../src/cancel/CancelToken'; diff --git a/test/core/flattenHeaders.test.ts b/test/core/flattenHeaders.test.ts index 7b3f71d..6e8873b 100644 --- a/test/core/flattenHeaders.test.ts +++ b/test/core/flattenHeaders.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 20:39:42 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 23:27:34 - */ import flattenHeaders from '../../src/core/flattenHeaders'; describe('测试 src/core/flattenHeaders.ts', () => { diff --git a/test/core/mergeConfig.test.ts b/test/core/mergeConfig.test.ts index 7ddaeab..0ce1b3c 100644 --- a/test/core/mergeConfig.test.ts +++ b/test/core/mergeConfig.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 19:16:32 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 11:48:12 - */ import { AxiosRequestConfig } from '../../src/types'; import mergeConfig from '../../src/core/mergeConfig'; import defaults from '../../src/defaults'; diff --git a/test/core/request.test.ts b/test/core/request.test.ts index e132d93..8dff227 100644 --- a/test/core/request.test.ts +++ b/test/core/request.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 22:51:26 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-21 09:37:30 - */ import request from '../../src/core/request'; import CancelToken from '../../src/cancel/CancelToken'; import isCancel from '../../src/cancel/isCancel'; diff --git a/test/core/transformData.test.ts b/test/core/transformData.test.ts index 9792e83..9af468b 100644 --- a/test/core/transformData.test.ts +++ b/test/core/transformData.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 20:31:29 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 20:38:49 - */ import { Data } from '../../src/types'; import transformData from '../../src/core/transformData'; diff --git a/test/core/transformMethod.test.ts b/test/core/transformMethod.test.ts index dd1a2ab..933ebec 100644 --- a/test/core/transformMethod.test.ts +++ b/test/core/transformMethod.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 16:14:52 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 16:17:39 - */ import { methodToLowercase, methodToUppercase } from '../../src/core/transformMethod'; describe('测试 src/core/transformMethod.ts', () => { diff --git a/test/core/transformRequest.test.ts b/test/core/transformRequest.test.ts index 634447c..2afa678 100644 --- a/test/core/transformRequest.test.ts +++ b/test/core/transformRequest.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 21:08:23 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-22 15:51:48 - */ import transformRequest from '../../src/core/transformRequest'; describe('测试 src/core/transformRequest.ts', () => { diff --git a/test/core/transformResponse.test.ts b/test/core/transformResponse.test.ts index c85be1a..e0c784f 100644 --- a/test/core/transformResponse.test.ts +++ b/test/core/transformResponse.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 21:25:08 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 21:34:20 - */ import transformResponse from '../../src/core/transformResponse'; describe('测试 src/core/transformResponse.ts', () => { diff --git a/test/helpers/buildURL.test.ts b/test/helpers/buildURL.test.ts index 67880e8..4c3a709 100644 --- a/test/helpers/buildURL.test.ts +++ b/test/helpers/buildURL.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-19 14:34:13 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 09:58:22 - */ import buildURL from '../../src/helpers/buildURL'; describe('测试 src/helpers/buildURL.ts', () => { diff --git a/test/helpers/combineURL.test.ts b/test/helpers/combineURL.test.ts index 8ad15a7..4412f09 100644 --- a/test/helpers/combineURL.test.ts +++ b/test/helpers/combineURL.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 09:42:17 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 09:58:41 - */ import combineURL from '../../src/helpers/combineURL'; describe('测试 src/helpers/combineURL.ts', () => { diff --git a/test/helpers/isAbsoluteURL.test.ts b/test/helpers/isAbsoluteURL.test.ts index 64e4f26..3bb31fb 100644 --- a/test/helpers/isAbsoluteURL.test.ts +++ b/test/helpers/isAbsoluteURL.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 09:42:17 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 10:27:07 - */ import isAbsoluteURL from '../../src/helpers/isAbsoluteURL'; describe('测试 src/helpers/isAbsoluteURL.ts', () => { diff --git a/test/helpers/utils.test.ts b/test/helpers/utils.test.ts index 2366a15..e7cd1dc 100644 --- a/test/helpers/utils.test.ts +++ b/test/helpers/utils.test.ts @@ -1,9 +1,3 @@ -/* - * @Author: early-autumn - * @Date: 2020-04-20 10:02:56 - * @LastEditors: early-autumn - * @LastEditTime: 2020-04-20 10:23:45 - */ import { encode, isDate, isPlainObject, deepMerge, pick, omit } from '../../src/helpers/utils'; describe('测试 src/helpers/utils.ts', () => {