{"size": 367, "ext": "js", "max_stars_repo_path": "src/chunk.js", "max_stars_repo_name": "hankaibo/mystone", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/chunk.js", "max_issues_repo_name": "hankaibo/mystone", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/chunk.js", "max_forks_repo_name": "hankaibo/mystone", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.3157894737, "max_line_length": 62, "alphanum_fraction": 0.5476839237}
/**
 * 将数组分成指定大小的较小数组。
 *
 * @since 0.0.1
 * @param {array} arr - 要分割的数组。
 * @param {number} size - 指定块的大小。
 * @return {array} 一个指定大小的新数组。
 * @example
 *
 * chunk([1,2,3,4,5], 2); // [[1,2],[3,4],[5]]
 */

const chunk = (arr, size) =>
  Array.from({length: Math.ceil(arr.length / size)}, (v, i) =>
    arr.slice(i * size, i * size + size)
  );

export default chunk;
