Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index argument to "transformHeader" config function #807

Merged
merged 1 commit into from Jun 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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