Class Index | File Index

Classes


Function Namespace Pot.repeat


Defined in: <potlite.js>.

Function Namespace Summary
Constructor Attributes Constructor Name and Description
 
Pot.repeat(max, callback, (context))
"repeat" loop iterates a specified number.
Field Summary
Field Attributes Field Name and Description
 
Iterates "repeat" loop with slower speed.
 
Iterates "repeat" loop with fast speed.
 
Iterates "repeat" loop with slowest speed.
 
Iterates "repeat" loop with fastest speed.
 
Iterates "repeat" loop with default speed.
 
Iterates "repeat" loop with faster speed.
 
Iterates "repeat" loop with slow speed.
Function Namespace Detail
Pot.repeat(max, callback, (context))
"repeat" loop iterates a specified number. The second argument of the callback function is passed the value to true only for the end of the loop. The first argument can pass as object that gives names "begin, end, step" any keys.
  var a = [];
  Pot.repeat(10, function(i) {
    a.push(i);
  });
  debug(a);
  // @results [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  //
  // The second argument of the callback function is
  //  passed the value to true only for the end of the loop.
  //
  var s = '', a = 'abcdef'.split('');
  Pot.repeat(a.length, function(i, last) {
    s += a[i] + '=' + i + (last ? ';' : ',');
  });
  debug(s);
  // @results 'a=0,b=1,c=2,d=3,e=4,f=5;'
  //
  // The first argument can pass as object
  //  that gives names "begin, end, step" any keys.
  //
  var a = [];
  Pot.repeat({begin: 0, end: 100, step: 10}, function(i) {
    a.push(i);
  });
  debug(a);
  // @results [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]
Parameters:
{Number|Object} max
The maximum number of times to loop, or object.
{Function} callback
An iterable function. Throw Pot.StopIteration if you want to stop the loop.
{*} (context)
Optionally, context object. (i.e. this)
Field Detail
{Function} doze
Iterates "repeat" loop with slower speed.

{Function} fast
Iterates "repeat" loop with fast speed.

{Function} limp
Iterates "repeat" loop with slowest speed.

{Function} ninja
Iterates "repeat" loop with fastest speed.

{Function} normal
Iterates "repeat" loop with default speed.

{Function} rapid
Iterates "repeat" loop with faster speed.

{Function} slow
Iterates "repeat" loop with slow speed.

Documentation generated by JsDoc Toolkit 2.4.0 on Fri Sep 21 2012 19:35:45 GMT+0900 (JST)