You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
378 B
22 lines
378 B
4 years ago
|
'use strict';
|
||
|
|
||
|
var values = require('../helpers/values');
|
||
|
|
||
|
module.exports = function shuffle() {
|
||
|
var items = values(this.items);
|
||
|
|
||
|
var j = void 0;
|
||
|
var x = void 0;
|
||
|
var i = void 0;
|
||
|
|
||
|
for (i = items.length; i; i -= 1) {
|
||
|
j = Math.floor(Math.random() * i);
|
||
|
x = items[i - 1];
|
||
|
items[i - 1] = items[j];
|
||
|
items[j] = x;
|
||
|
}
|
||
|
|
||
|
this.items = items;
|
||
|
|
||
|
return this;
|
||
|
};
|