Class Index | File Index

Classes


Class Pot.Deferred#zip


Defined in: <potlite.js>.

Class Summary
Constructor Attributes Constructor Name and Description
 
Pot.Deferred#zip((callback), (context))
Create a new array which has the elements at position ith of the provided arrays.
Field Summary
Field Attributes Field Name and Description
 
Iterates "zip" loop with slower speed.
 
Iterates "zip" loop with fast speed.
 
Iterates "zip" loop with slowest speed.
 
Iterates "zip" loop with fastest speed.
 
Iterates "zip" loop with default speed.
 
Iterates "zip" loop with faster speed.
 
Iterates "zip" loop with slow speed.
Class Detail
Pot.Deferred#zip((callback), (context))
Create a new array which has the elements at position ith of the provided arrays. This function is handled as seen from the longitudinal for array that is similar to the zip() function in Python.
Example:

  arguments:  [[1, 2, 3],
               [4, 5, 6]]

  results:    [[1, 4],
               [2, 5],
               [3, 6]]
  var d = new Deferred();
  d.then(function() {
    return [[1, 2, 3], [4, 5, 6]];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [[1, 4], [2, 5], [3, 6]]
    //
  }).begin();
  var d = new Deferred();
  d.then(function() {
    return [[1, 2, 3], [1, 2, 3, 4, 5]];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [[1, 1], [2, 2], [3, 3]]
    //
  }).begin();
  var d = new Deferred();
  d.then(function() {
    return [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11]];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [[1, 4, 7, 10], [2, 5, 8, 11]]
    //
  }).begin();
  begin(function() {
    return ['hoge'];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [['hoge']]
    //
  });
  begin(function() {
    return [[1], [2], [3]];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [[1, 2, 3]]
    //
  });
  begin(function() {
    return [[1, 2, 3], ['foo', 'bar', 'baz'], [4, 5]];
  }).zip().then(function(res) {
    debug(res);
    // @results
    //     [[1, 'foo', 4], [2, 'bar', 5]]
    //
  });
  var callback = function(items) { return items[0] + items[1]; };
  begin(function() {
    return [[1, 2, 3], [4, 5, 6]];
  }).zip(callback).then(function(res) {
    debug(res);
    // @results [5, 7, 9]
  });
Parameters:
{Function} (callback)
(Optional) Callback function. function({Array} items[, {*} object]) this == `context`.
{*} (context)
(Optional) Object to use as `this` when executing callback.
Returns:
{Array} A new array of arrays created from provided objects.
See:
http://docs.python.org/library/functions.html#zip
Field Detail
{Function} doze
Iterates "zip" loop with slower speed.

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

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

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

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

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

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

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