From ff4cd93ae453f6a074086a3c35b35a61a10fb5b4 Mon Sep 17 00:00:00 2001 From: zhengxs Date: Fri, 23 Apr 2021 20:26:21 +0800 Subject: [PATCH] =?UTF-8?q?CI=20=E8=A7=A6=E5=8F=91=E6=B5=8B=E8=AF=95=20(#2?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: 触发性测试 --- .github/workflows/release-package.yml | 1 + src/array.ts | 15 +-------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release-package.yml b/.github/workflows/release-package.yml index 6d1fffb..7beebee 100644 --- a/.github/workflows/release-package.yml +++ b/.github/workflows/release-package.yml @@ -7,6 +7,7 @@ on: - beta paths: - "src/**/*" + - "!src/**/*.spec.ts" - package.json pull_request: branches: diff --git a/src/array.ts b/src/array.ts index d7600f7..3d58df1 100644 --- a/src/array.ts +++ b/src/array.ts @@ -5,19 +5,6 @@ */ export type UniqueComparator = (value: T, next: T[], index: number, result: T[]) => boolean -/** - * 默认唯一性比较函数 - * - * - * @param current - 当前比对项 - * @param array - 后续的所有项 - * - * @returns 判断结果 - */ -function defaultUniqueComparator(current: T, array: T[]): boolean { - return array.indexOf(current) > -1 -} - /** * 数组唯一性处理 * @@ -61,7 +48,7 @@ function defaultUniqueComparator(current: T, array: T[]): boolean { * // -> ['a', 'b', 'c', '', 1, 0] * ``` */ -export function unique(array: T[], comparator: UniqueComparator = defaultUniqueComparator): T[] { +export function unique(array: T[], comparator: UniqueComparator = (v, a) => a.indexOf(v) > -1): T[] { return array.reduce((result, value, index) => { const flag = comparator(value, array.slice(index + 1), index, result) return flag ? result : result.concat(value)