refactor: adapter 移动到 src 目录

pull/41/head
zjx0905 2023-03-24 20:15:51 +08:00
parent acb110bd41
commit 0228482c8b
15 changed files with 25 additions and 15 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -35,5 +35,8 @@ jobs:
- name: Build
run: pnpm build -a
- name: Build zip
run: pnpm build:zip
- name: Test
run: pnpm test

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
node_modules
dist
.eslintcache
.DS_Store
.idea

View File

@ -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) => {

BIN
src/.DS_Store vendored

Binary file not shown.

View File

@ -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';

View File

@ -1,4 +1,4 @@
import { AxiosAdapter, createAdapter, AxiosPlatform } from './core/adapter';
import { AxiosAdapter, createAdapter, AxiosPlatform } from './adapter';
import Axios, {
AxiosConstructor,
AxiosRequestConfig,

View File

@ -4,7 +4,7 @@ import {
AxiosAdapterRequestMethod,
AxiosAdapter,
AxiosAdapterTask,
} from './adapter';
} from '../adapter';
import { CancelToken } from './cancel';
import dispatchRequest from './dispatchRequest';
import InterceptorManager from './InterceptorManager';

View File

@ -1,4 +1,4 @@
import { AxiosAdapterTask } from './adapter';
import { AxiosAdapterTask } from '../adapter';
import { AxiosRequestConfig, AxiosResponse, AxiosResponseError } from './Axios';
export type AxiosErrorResponse = AxiosResponse | AxiosResponseError;

View File

@ -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(

View File

@ -4,7 +4,7 @@ import {
AxiosAdapterRequestConfig,
AxiosAdapterRequestMethod,
AxiosAdapterTask,
} from './adapter';
} from '../adapter';
import {
AxiosProgressCallback,
AxiosRequestConfig,

View File

@ -1,4 +1,4 @@
import { getAdapterDefault } from './core/adapter';
import { getAdapterDefault } from './adapter';
import { AxiosRequestConfig } from './core/Axios';
const defaults: AxiosRequestConfig = {

View File

@ -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';
}

View File

@ -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;
}

View File

@ -10,6 +10,6 @@ export type {
AxiosAdapterRequestConfig,
AxiosAdapter,
AxiosPlatform,
} from './core/adapter';
} from './adapter';
export type { AxiosInstance, AxiosStatic } from './axios';
export default axios;