diff --git a/docs/collection/merge-with.md b/docs/collection/merge-with.md index 8f35be0..aceea1d 100644 --- a/docs/collection/merge-with.md +++ b/docs/collection/merge-with.md @@ -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 diff --git a/docs/number/delay.md b/docs/number/delay.md index b767f2b..4e0f2cd 100644 --- a/docs/number/delay.md +++ b/docs/number/delay.md @@ -14,8 +14,8 @@ console.log('End after 1 second') ### Arguments -| Arg | Type | Defaults | -| --------------------- | :------: | -------: | +| Arg | Type | Defaults | +| ----------- | :------: | -------: | | `time (ms)` | `number` | | ### Return diff --git a/docs/zh/function/call.md b/docs/zh/function/call.md index 56bd613..75d8275 100644 --- a/docs/zh/function/call.md +++ b/docs/zh/function/call.md @@ -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] ``` diff --git a/docs/zh/math/mean.md b/docs/zh/math/mean.md index 93f2e2e..3cdbfbb 100644 --- a/docs/zh/math/mean.md +++ b/docs/zh/math/mean.md @@ -13,12 +13,12 @@ mean([10, 20, 30]) // return 20 ### 参数列表 -| 参数 | 类型 | 默认值 | -| ----- | :---------: | -----: | -| `arr` | `number[]` | | +| 参数 | 类型 | 默认值 | +| ----- | :--------: | -----: | +| `arr` | `number[]` | | ### 返回值 -| 类型 | -| :-------: | -| `number` | \ No newline at end of file +| 类型 | +| :------: | +| `number` | diff --git a/src/math.ts b/src/math.ts index 51c2d94..04158ed 100644 --- a/src/math.ts +++ b/src/math.ts @@ -13,7 +13,7 @@ export function minBy(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(arr: T[], fn: (val: T) => number) { @@ -21,7 +21,7 @@ export function maxBy(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 mean(arr: number[]) {