Skip to content

Commit

Permalink
Add index argument to transformHeader (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
furey committed Jun 24, 2020
1 parent 6f997ef commit 018f5df
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions papaparse.js
Expand Up @@ -1189,24 +1189,24 @@ License: MIT
if (!_results)
return;

function addHeder(header)
function addHeader(header, i)
{
if (isFunction(_config.transformHeader))
header = _config.transformHeader(header);
header = _config.transformHeader(header, i);

_fields.push(header);
}

if (Array.isArray(_results.data[0]))
{
for (var i = 0; needsHeaderRow() && i < _results.data.length; i++)
_results.data[i].forEach(addHeder);
_results.data[i].forEach(addHeader);

_results.data.splice(0, 1);
}
// if _results.data[0] is not an array, we are in a step where _results.data is the row.
else
_results.data.forEach(addHeder);
_results.data.forEach(addHeader);
}

function shouldApplyDynamicTyping(field) {
Expand Down

0 comments on commit 018f5df

Please sign in to comment.