refactor: adapter 移动到 src 目录
parent
acb110bd41
commit
0228482c8b
|
@ -35,5 +35,8 @@ jobs:
|
|||
- name: Build
|
||||
run: pnpm build -a
|
||||
|
||||
- name: Build zip
|
||||
run: pnpm build:zip
|
||||
|
||||
- name: Test
|
||||
run: pnpm test
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
node_modules
|
||||
dist
|
||||
.eslintcache
|
||||
.DS_Store
|
||||
.idea
|
||||
|
|
|
@ -25,7 +25,11 @@ function generateZip(inputPath: string, outputPath: string) {
|
|||
|
||||
const start = Date.now();
|
||||
JSZip()
|
||||
.file(inputName, fs.createReadStream(inputPath))
|
||||
.file(inputName, fs.createReadStream(inputPath), {
|
||||
compressionOptions: {
|
||||
level: 9,
|
||||
},
|
||||
})
|
||||
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
|
||||
.pipe(fs.createWriteStream(outputPath))
|
||||
.on('finish', (result) => {
|
||||
|
|
Binary file not shown.
|
@ -4,8 +4,8 @@ import {
|
|||
isPlainObject,
|
||||
isString,
|
||||
isUndefined,
|
||||
} from '../helpers/is';
|
||||
import { assert, throwError } from '../helpers/utils';
|
||||
} from './helpers/is';
|
||||
import { assert, throwError } from './helpers/utils';
|
||||
import {
|
||||
AxiosProgressCallback,
|
||||
AxiosRequestConfig,
|
||||
|
@ -14,7 +14,7 @@ import {
|
|||
AxiosRequestHeaders,
|
||||
AxiosResponse,
|
||||
AxiosResponseError,
|
||||
} from './Axios';
|
||||
} from './core/Axios';
|
||||
|
||||
export type AxiosAdapterRequestType = 'request' | 'download' | 'upload';
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { AxiosAdapter, createAdapter, AxiosPlatform } from './core/adapter';
|
||||
import { AxiosAdapter, createAdapter, AxiosPlatform } from './adapter';
|
||||
import Axios, {
|
||||
AxiosConstructor,
|
||||
AxiosRequestConfig,
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
AxiosAdapterRequestMethod,
|
||||
AxiosAdapter,
|
||||
AxiosAdapterTask,
|
||||
} from './adapter';
|
||||
} from '../adapter';
|
||||
import { CancelToken } from './cancel';
|
||||
import dispatchRequest from './dispatchRequest';
|
||||
import InterceptorManager from './InterceptorManager';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AxiosAdapterTask } from './adapter';
|
||||
import { AxiosAdapterTask } from '../adapter';
|
||||
import { AxiosRequestConfig, AxiosResponse, AxiosResponseError } from './Axios';
|
||||
|
||||
export type AxiosErrorResponse = AxiosResponse | AxiosResponseError;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { toLowerCase } from '../helpers/utils';
|
||||
import { AxiosAdapterRequestType } from './adapter';
|
||||
import { AxiosAdapterRequestType } from '../adapter';
|
||||
import { AxiosRequestConfig, AxiosRequestMethodAlias } from './Axios';
|
||||
|
||||
export function generateType(
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
AxiosAdapterRequestConfig,
|
||||
AxiosAdapterRequestMethod,
|
||||
AxiosAdapterTask,
|
||||
} from './adapter';
|
||||
} from '../adapter';
|
||||
import {
|
||||
AxiosProgressCallback,
|
||||
AxiosRequestConfig,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getAdapterDefault } from './core/adapter';
|
||||
import { getAdapterDefault } from './adapter';
|
||||
import { AxiosRequestConfig } from './core/Axios';
|
||||
|
||||
const defaults: AxiosRequestConfig = {
|
||||
|
|
|
@ -16,7 +16,8 @@ export function isEmptyObject(value: any): value is object {
|
|||
return isPlainObject(value) && Object.keys(value).length === 0;
|
||||
}
|
||||
|
||||
export function isFunction<T extends () => void>(value: any): value is T {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function isFunction<T extends Function>(value: any): value is T {
|
||||
return typeof value === 'function';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { isPlainObject, isString } from './is';
|
||||
|
||||
export function deepMerge<T = unknown>(...objs: T[]): T {
|
||||
export function deepMerge<T extends AnyObject>(...objs: T[]): T {
|
||||
const result: AnyObject = {};
|
||||
|
||||
objs.forEach((obj: AnyObject) =>
|
||||
|
@ -53,7 +53,7 @@ export function throwError(msg: string): void {
|
|||
throw new Error(`[axios-miniprogram]: ${msg}`);
|
||||
}
|
||||
|
||||
export function toLowerCase<T extends string>(value: unknown, defaultValue: T): T {
|
||||
export function toLowerCase<T extends string>(value: any, defaultValue: T): T {
|
||||
if (!isString(value)) {
|
||||
value = defaultValue;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export function toLowerCase<T extends string>(value: unknown, defaultValue: T):
|
|||
return value.toLowerCase() as T;
|
||||
}
|
||||
|
||||
export function toUpperCase<T extends string>(value: unknown, defaultValue: T): T {
|
||||
export function toUpperCase<T extends string>(value: any, defaultValue: T): T {
|
||||
if (!isString(value)) {
|
||||
value = defaultValue;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ export type {
|
|||
AxiosAdapterRequestConfig,
|
||||
AxiosAdapter,
|
||||
AxiosPlatform,
|
||||
} from './core/adapter';
|
||||
} from './adapter';
|
||||
export type { AxiosInstance, AxiosStatic } from './axios';
|
||||
export default axios;
|
||||
|
|
Loading…
Reference in New Issue