Skip to content

Commit

Permalink
fix(chunk): array 为空时应直接返回空数组
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Apr 25, 2019
1 parent 8970621 commit 99f177b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import { isFunction } from './isFunction'
* @returns 拆分后的新数组
*/
export function chunk<T, F = never>(array: T[], size: number, filler?: ((index: number) => F) | F): (T | F)[][] {
if (array.length === 0) {
return []
}
size = Math.max(size, 1)
const result: (T | F)[][] = []
const rows = Math.ceil(array.length / size)
Expand Down

0 comments on commit 99f177b

Please sign in to comment.