From a835e6d4accf45b511f9e4eb7535d2a20e9ffa3a Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Sat, 17 Jun 2023 18:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ensureArray=E7=9A=84=E5=BC=95?= =?UTF-8?q?=E5=85=A5=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/loader/resource.ts | 2 +- src/plugin/utils.ts | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/loader/resource.ts b/src/core/loader/resource.ts index 6f61df3..47096d1 100644 --- a/src/core/loader/resource.ts +++ b/src/core/loader/resource.ts @@ -1,6 +1,6 @@ import axios, { AxiosResponse } from 'axios'; import { Disposable } from '../common/disposable'; -import { ensureArray } from '../../plugin/game/utils'; +import { ensureArray } from '../../plugin/utils'; import { has } from '../../plugin/utils'; import JSZip from 'jszip'; import { EmitableEvent, EventEmitter } from '../common/eventEmitter'; diff --git a/src/plugin/utils.ts b/src/plugin/utils.ts index 26de6b8..1efc3bf 100644 --- a/src/plugin/utils.ts +++ b/src/plugin/utils.ts @@ -253,3 +253,8 @@ export async function swapChapter(chapter: number, hard: number) { core.drawTip('读档成功'); }); } + +export function ensureArray(arr: T): T extends any[] ? T : T[] { + // @ts-ignore + return arr instanceof Array ? arr : [arr]; +}