index.js 406 B

123456789101112131415
  1. 'use strict';
  2. const spinners = Object.assign({}, require('./spinners.json')); // eslint-disable-line import/extensions
  3. const spinnersList = Object.keys(spinners);
  4. Object.defineProperty(spinners, 'random', {
  5. get() {
  6. const randomIndex = Math.floor(Math.random() * spinnersList.length);
  7. const spinnerName = spinnersList[randomIndex];
  8. return spinners[spinnerName];
  9. }
  10. });
  11. module.exports = spinners;