瀏覽代碼

Added a range() method to Utils which will return an array containing values from a to b over a given step.

dev-tmpl
Bryan Miller 5 年之前
父節點
當前提交
26352e888d
共有 1 個文件被更改,包括 18 次插入0 次删除
  1. +18
    -0
      app/js/common/Utils.js

+ 18
- 0
app/js/common/Utils.js 查看文件

@@ -24,6 +24,24 @@ const utils = {
}
},

range:function(a, b, step){
var arr = [];
if (!isNaN(a) && !isNaN(b)){
if (a == b || step < 0){
arr.push(a);
} else {
if (a < b){
for (var i=a; i <= b; i+=step)
arr.push(i);
} else {
for (var i=a; i >= b; i-=step)
arr.push(i);
}
}
}
return arr;
},

debounce:function(func, delay, scope){
var timeout = null;
return function(){

Loading…
取消
儲存