File tree Expand file tree Collapse file tree 1 file changed +23
-17
lines changed Expand file tree Collapse file tree 1 file changed +23
-17
lines changed Original file line number Diff line number Diff line change 1- /**
2- * The shuffling algorithm of
3- * Fisher-Yates. Complexity O(n)
4- *
5- * @param {array } array The array which should be shuffled
6- * @return {array } The shuffled array.
7- */
8- function shuffle ( array ) {
1+ ( function ( exports ) {
92 'use strict' ;
10- var size = array . length ,
11- rand , temp ;
12- for ( var i = 1 ; i < size ; i += 1 ) {
13- rand = Math . round ( Math . random ( ) * i ) ;
14- temp = array [ rand ] ;
15- array [ rand ] = array [ i ] ;
16- array [ i ] = temp ;
3+
4+ /**
5+ * The shuffling algorithm of
6+ * Fisher-Yates. Complexity O(n)
7+ *
8+ * @param {array } array The array which should be shuffled
9+ * @return {array } The shuffled array.
10+ */
11+ function shuffle ( array ) {
12+ var size = array . length ,
13+ rand , temp ;
14+ for ( var i = 1 ; i < size ; i += 1 ) {
15+ rand = Math . round ( Math . random ( ) * i ) ;
16+ temp = array [ rand ] ;
17+ array [ rand ] = array [ i ] ;
18+ array [ i ] = temp ;
19+ }
20+ return array ;
1721 }
18- return array ;
19- }
22+
23+ exports . shuffle = shuffle ;
24+
25+ } ( typeof exports === 'undefined' ? window : exports ) ) ;
2026
You can’t perform that action at this time.
0 commit comments