Add generic helper utils

old
Javi Velasco 2015-09-05 02:03:32 +02:00
parent 88dc8f691b
commit ae47335284
1 changed files with 19 additions and 0 deletions

19
components/util/helper.js Normal file
View File

@ -0,0 +1,19 @@
module.exports = {
range (start, stop, step = 1) {
if (stop == null) {
stop = start || 0;
start = 0;
}
let length = Math.max(Math.ceil((stop - start) / step), 0);
let range = Array(length);
for (const idx = 0; idx < length; idx++, start += step) {
range[idx] = start;
}
return range;
}
};