From 410e0c29433bea3886a14b4a8fa3835afd7f3ba3 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 29 Oct 2026 20:28:46 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=20legacy-common?= =?UTF-8?q?=20=E7=9A=84=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/legacy-common/src/index.ts | 1 - packages/legacy-common/src/utils.ts | 47 ----------------------------- 2 files changed, 48 deletions(-) delete mode 100644 packages/legacy-common/src/utils.ts diff --git a/packages/legacy-common/src/index.ts b/packages/legacy-common/src/index.ts index 85a0b52..d8b82c2 100644 --- a/packages/legacy-common/src/index.ts +++ b/packages/legacy-common/src/index.ts @@ -1,2 +1 @@ export * from './eventEmitter'; -export * from './utils'; diff --git a/packages/legacy-common/src/utils.ts b/packages/legacy-common/src/utils.ts deleted file mode 100644 index 7e8a0a3..0000000 --- a/packages/legacy-common/src/utils.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { EVENT_KEY_CODE_MAP } from '@motajs/client-base'; - -export function flipBinary(num: number, col: number) { - const n = 1 << col; - if (num & n) return num & ~n; - else return num | n; -} - -/** - * 根据布尔值数组转换成一个二进制数 - * @param arr 要转换的布尔值数组 - */ -export function generateBinary(arr: boolean[]) { - let num = 0; - arr.forEach((v, i) => { - if (v) { - num |= 1 << i; - } - }); - return num; -} - -/** - * 删除数组内的某个项,返回删除后的数组 - * @param arr 要操作的数组 - * @param ele 要删除的项 - */ -export function deleteWith(arr: T[], ele: T): T[] { - const index = arr.indexOf(ele); - if (index === -1) return arr; - arr.splice(index, 1); - return arr; -} - -export function spliceBy(arr: T[], from: T): T[] { - const index = arr.indexOf(from); - if (index === -1) return []; - return arr.splice(index); -} - -/** - * 获取事件中的keycode对应的键 - * @param key 要获取的键 - */ -export function keycode(key: number) { - return EVENT_KEY_CODE_MAP[key]; -}