This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//fn为要节流的操作,interval为最小操作间隔 | |
var throttle = function(fn, interval){ | |
var timer, | |
_fn = fn;//保存要延时的函数的引用 | |
return function(){ | |
var that = this; | |
var arg = arguments; | |
//如果有未完成的计时器,则不进行操作 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ary为要批量处理的数据,fn为对每个数据的操作方式,count为每次处理的量 | |
var timechunk = function(ary, fn, count){ | |
var obj, | |
timer; | |
var start = function(){ | |
for(var i = 0; i < count; i++){ | |
if(ary.length === 0){ | |
return; | |
} | |
obj = ary.shift(); |
NewerOlder