Skip to content

style: format code #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading