Browse Source

Added util function for range generation

Pavel Ševčík 3 years ago
parent
commit
840b7fa26e
No known key found for this signature in database GPG Key ID: CFA54E4C0CD58DF0
  1. 13
      lib/util.js

13
lib/util.js

@ -351,6 +351,19 @@ class Util {
}
}
/**
* @description Generate array of sequential numbers from start to stop
* @param {number} start
* @param {number} stop
* @param {number=} step
* @returns {number[]}
*/
static range(start, stop, step = 1) {
return Array(Math.ceil((stop - start) / step))
.fill(start)
.map((x, y) => x + y * step)
}
}
/**

Loading…
Cancel
Save