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.

21 lines
378 B

4 years ago
  1. 'use strict';
  2. var values = require('../helpers/values');
  3. module.exports = function shuffle() {
  4. var items = values(this.items);
  5. var j = void 0;
  6. var x = void 0;
  7. var i = void 0;
  8. for (i = items.length; i; i -= 1) {
  9. j = Math.floor(Math.random() * i);
  10. x = items[i - 1];
  11. items[i - 1] = items[j];
  12. items[j] = x;
  13. }
  14. this.items = items;
  15. return this;
  16. };