Skip to content

Commit

Permalink
style: format code (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
chouchouji authored Oct 31, 2024
1 parent aad4f13 commit 203a006
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
13 changes: 5 additions & 8 deletions docs/collection/merge-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ Merge two objects recursively, allowing for custom merge logic through a callbac
```ts
import { mergeWith } from 'rattail'

mergeWith(
{ a: [1, 2] }, { a: [3, 4] },
(objValue, srcValue) => [...objValue, ...srcValue]
)
mergeWith({ a: [1, 2] }, { a: [3, 4] }, (objValue, srcValue) => [...objValue, ...srcValue])
// return: { a: [ 1, 2, 3, 4 ] }
```

### Arguments

| Arg | Type | Defaults |
| ---------- | ----------------------------------------------------------------------------------------- | -------- |
| `object` | `object` | |
| `source` | `object` | |
| Arg | Type | Defaults |
| ---------- | --------------------------------------------------------------------------------- | -------- |
| `object` | `object` | |
| `source` | `object` | |
| `callback` | `(objValue: any, srcValue: any, key: any, object: object, source: object) => any` | |

### Return
Expand Down
4 changes: 2 additions & 2 deletions docs/number/delay.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ console.log('End after 1 second')

### Arguments

| Arg | Type | Defaults |
| --------------------- | :------: | -------: |
| Arg | Type | Defaults |
| ----------- | :------: | -------: |
| `time (ms)` | `number` | |

### Return
Expand Down
4 changes: 2 additions & 2 deletions docs/zh/function/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
```ts
import { call } from 'rattail'

call((a, b) => a + b, 1, 2)
call((a, b) => a + b, 1, 2)
// return 3
call([(a, b) => a + b, (a, b) => a + b], 1, 2)
call([(a, b) => a + b, (a, b) => a + b], 1, 2)
// return [3, 3]
```

Expand Down
12 changes: 6 additions & 6 deletions docs/zh/math/mean.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ mean([10, 20, 30]) // return 20

### 参数列表

| 参数 | 类型 | 默认值 |
| ----- | :---------: | -----: |
| `arr` | `number[]` | |
| 参数 | 类型 | 默认值 |
| ----- | :--------: | -----: |
| `arr` | `number[]` | |

### 返回值

| 类型 |
| :-------: |
| `number` |
| 类型 |
| :------: |
| `number` |
4 changes: 2 additions & 2 deletions src/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ export function minBy<T>(arr: T[], fn: (val: T) => number) {
return
}

return arr.reduce((result, item) => fn(result) < fn(item) ? result : item, arr[0])
return arr.reduce((result, item) => (fn(result) < fn(item) ? result : item), arr[0])
}

export function maxBy<T>(arr: T[], fn: (val: T) => number) {
if (!arr.length) {
return
}

return arr.reduce((result, item) => fn(result) > fn(item) ? result : item, arr[0])
return arr.reduce((result, item) => (fn(result) > fn(item) ? result : item), arr[0])
}

export function mean(arr: number[]) {
Expand Down

0 comments on commit 203a006

Please sign in to comment.