util.js 344 B

123456789101112131415161718192021
  1. 'use strict';
  2. /**
  3. * Create an array of numbers.
  4. * @param {number} from
  5. * @param {number} to
  6. * @returns {number[]}
  7. */
  8. function range(from, to) {
  9. // TODO: make this inlined.
  10. const list = new Array(to - from + 1);
  11. for (let i = 0; i < list.length; i += 1) {
  12. list[i] = from + i;
  13. }
  14. return list;
  15. }
  16. module.exports = {
  17. range,
  18. };