From ae473352848bf54ebc32293fda02c0e5eae5c2b0 Mon Sep 17 00:00:00 2001 From: Javi Velasco Date: Sat, 5 Sep 2015 02:03:32 +0200 Subject: [PATCH] Add generic helper utils --- components/util/helper.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 components/util/helper.js diff --git a/components/util/helper.js b/components/util/helper.js new file mode 100644 index 00000000..0f375411 --- /dev/null +++ b/components/util/helper.js @@ -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; + } + +};