UNPKG

wireit

Version:

Upgrade your npm scripts to make them smarter and more efficient

16 lines • 465 B
/** * @license * Copyright 2022 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Randomize the order of an array in-place. */ export const shuffle = (array) => { // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } }; //# sourceMappingURL=shuffle.js.map