jskata.nofreeze
jsKata.nofreeze avoids freezing by splitting long processes into smaller ones.
Read more at http://www.javascriptkata.com/2010/08/10/nofreeze-a-library-that-avoids-freezing-in-javascript/
sleepFor integer (default 1) : How many milliseconds should it sleeps
chunkSize integer (default 10) : How many executions before sleep
stops [functions] : Contains all the stop functions started in a different processes
forloop(wh, inc, fct, options{sleepFor:integer, chunkSize:integer}, stopCallback) returns {stop:function}
wh function (should return boolean) : The while condition
inc function : The increment
fct function : The function to execute
options hash : Options
sleepFor integer : How many milliseconds should it sleeps
chunkSize integer : How many executions before sleep
stopCallback hash : Called when the process is stopped
stop function : Call this function to stop the process
This function looks like the basic for except that wh and inc are functions. Instead of
for(var i = 0; i < 1000; i++) {
alert(i);
}
you write
var i = 0;
jsk.nofreeze.for(
function() {return i < 1000},
function() {i++},
function() {alert(i)}
)
maxCount integer : couting up to this number
fct function : The function to execute
index integer : The current index of the loop
options hash :
beginAt integer : From which number should the count begin (default 0)
see options in forloop
This is a simpler loop.
for(var i = 0; i < 1000; i++) {
alert(i);
}
would become
var i = 0;
jsk.nofreeze.forCount(1000,
function() {alert(i)}
)
fct function : The function to execute
options hash of [sleepFor|chunkSize] : To override defaults
stopCallback hash : Called when the process is stopped
stop function : Call this function to stop the process
Starts an infinite loop.
obj array or object : Can be an array or an object
fct function : The function to execute
index integer : The current index of the loop
item object : The current object of the loop
options hash of [sleepFor|chunkSize] : To override defaults
stopCallback hash : Called when the process is stopped
stop function : Call this function to stop the process
Loop through each of the element of an array.
Stop all the processes
no callbacks