src/js/db/table.js
/**
* Map a function on a table object
* @param {Function} Fun Function to be maped
* @param {Table} Tbl table element
* @param {Array.(Number|String)} Inputs preselected colum values
* @return {Table} Tbl table element
*/
Map a function on a table object
Map a function on a table object
function map(Fun, Tbl, Inputs) {
  var Data = Tbl.data, i;
  if (Inputs){
    var B,In = amap(Inputs,function(D){col(Tbl,D)});
    for (i = 0; i < Data.length; i++) {
      B = amap( function(I){return this[I];}.bind(Data[i]),In);
      Data[i] = Fun.apply(null,[Data[i]].concat(B),i);
    }
  } else {
    for (i = 0; i < Data.length; i++) {
      Data[i] = Fun(Data[i],i);
    }
  }
  return Tbl;
}
function map ( Fun , Tbl , Inputs ) { var Data = Tbl . data , i ; if ( Inputs ) { var B , In = amap ( Inputs , function ( D ) { col ( Tbl , D ) } ) ; for ( i = 0 ; i < Data . length ; i ++ ) { B = amap ( function ( I ) { return this [ I ] ; } . bind ( Data [ i ] ) , In ) ; Data [ i ] = Fun . apply ( null , [ Data [ i ] ] . concat ( B ) , i ) ; } } else { for ( i = 0 ; i < Data . length ; i ++ ) { Data [ i ] = Fun ( Data [ i ] , i ) ; } } return Tbl ; }
Map a function on a table object
Map a function on a table object