Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
CI 触发测试 (#2)
Browse files Browse the repository at this point in the history
* ci: 触发性测试
  • Loading branch information
zhengxs2018 authored Apr 23, 2021
1 parent 83e13a8 commit ff4cd93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- beta
paths:
- "src/**/*"
- "!src/**/*.spec.ts"
- package.json
pull_request:
branches:
Expand Down
15 changes: 1 addition & 14 deletions src/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@
*/
export type UniqueComparator<T> = (value: T, next: T[], index: number, result: T[]) => boolean

/**
* 默认唯一性比较函数
*
*
* @param current - 当前比对项
* @param array - 后续的所有项
*
* @returns 判断结果
*/
function defaultUniqueComparator<T = unknown>(current: T, array: T[]): boolean {
return array.indexOf(current) > -1
}

/**
* 数组唯一性处理
*
Expand Down Expand Up @@ -61,7 +48,7 @@ function defaultUniqueComparator<T = unknown>(current: T, array: T[]): boolean {
* // -> ['a', 'b', 'c', '', 1, 0]
* ```
*/
export function unique<T = unknown>(array: T[], comparator: UniqueComparator<T> = defaultUniqueComparator): T[] {
export function unique<T = unknown>(array: T[], comparator: UniqueComparator<T> = (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)
Expand Down

0 comments on commit ff4cd93

Please sign in to comment.