UNPKG

ut2

Version:

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

17 lines (16 loc) 454 B
/** * 创建一个被打乱的数组。使用 [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle) 版本。 * * @alias module:Array.shuffle * @since 1.0.0 * @param {Array} array 要打乱的数组。 * @returns {Array} 打乱的数组。 * @example * * shuffle([1, 2, 3, 4]); // [2, 4, 3, 1] * * shuffle([1, 2, 3, 4]); // [3, 2, 1, 4] * */ declare function shuffle<T>(array: T[]): T[]; export default shuffle;