diff --git a/docs/number/times.md b/docs/number/times.md index 868b4f8..bc9cf66 100644 --- a/docs/number/times.md +++ b/docs/number/times.md @@ -15,13 +15,13 @@ times(5, (index) => `Item ${index}`) ### Arguments -| Arg | Type | Defaults | -| ----- | :--------------------: | -------: | -| `num` | `number` | | -| `fn` | `(index: number) => T` | | +| Arg | Type | Defaults | +| ----- | :----------------------: | -------: | +| `num` | `number` | | +| `fn` | `(index: number) => any` | | ### Return -| Type | -| :---: | -| `T[]` | +| Type | +| :-----: | +| `Array` | diff --git a/docs/zh/number/times.md b/docs/zh/number/times.md index 2a94862..892f385 100644 --- a/docs/zh/number/times.md +++ b/docs/zh/number/times.md @@ -15,13 +15,13 @@ times(5, (index) => `Item ${index}`) ### 参数 -| 参数 | 类型 | 默认值 | -| ----- | :--------------------: | -----: | -| `num` | `number` | | -| `fn` | `(index: number) => T` | | +| 参数 | 类型 | 默认值 | +| ----- | :----------------------: | -----: | +| `num` | `number` | | +| `fn` | `(index: number) => any` | | ### 返回值 -| 类型 | -| :---: | -| `T[]` | +| 类型 | +| :-----: | +| `Array` | diff --git a/src/number/times.ts b/src/number/times.ts index 912f731..a63639a 100644 --- a/src/number/times.ts +++ b/src/number/times.ts @@ -1,3 +1,3 @@ -export function times(num: number, fn: (index: number) => T) { +export function times(num: number, fn: (index: number) => T): T[] { return Array.from({ length: num }, (_, index) => fn(index)) }