UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

29 lines (28 loc) 745 B
interface List { <T>(n: number, iteratee: (index: number) => T): T[]; (n: number): number[]; } /** * 调用 `iteratee` `n` 次,每次调用返回的结果存入到数组中。 * * `iteratee` 调用传入一个参数 `index`。 * * *注:原方法名为 `times`,自 `v1.12.0` 版本调整为 `list`。* * * @function * @alias module:Util.list * @since 1.12.0 * @param {number} n 调用 `iteratee` 的次数。 * @param {Function} [iteratee=identity] 每次迭代调用的函数。默认 `identity`。 * @returns {Array} 调用结果的数组。 * @example * * list(3); // [0, 1, 2] * * list(3, String); // ['0', '1', '2'] * * list(4, () => 0); // [0, 0, 0, 0] * */ declare const list: List; export default list;