Class Index | File Index

Classes


Function Namespace Pot.map


Defined in: <pot.js>.

Function Namespace Summary
Constructor Attributes Constructor Name and Description
 
Pot.map(object, callback, (context))
Creates a new object with the results of calling a provided function on every element in object.
Function Namespace Detail
Pot.map(object, callback, (context))
Creates a new object with the results of calling a provided function on every element in object. This method like Array.prototype.map
  function fuzzyPlural(single) {
    return single.replace(/o/g, 'e');
  }
  var words = ['foot', 'goose', 'moose'];
  debug(Pot.map(words, fuzzyPlural));
  // @results ['feet', 'geese', 'meese']
  var object = {foo: 'foo1', bar: 'bar2', baz: 'baz3'};
  var result = Pot.map(object, function(value, key) {
    return value + '00';
  });
  debug(result);
  // @results {foo: 'foo100', bar: 'bar200', baz: 'baz300'}
Parameters:
{Array|Object|*} object
A target object.
{Function} callback
A callback function.
{*} (context)
(Optional) Object to use as `this` when executing callback.
Returns:
{*} Return the result of each callbacks.

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