Browse Source

Add index argument to transformHeader (#807)

pull/810/head
James Furey 5 years ago committed by GitHub
parent
commit
018f5dfe41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      papaparse.js

8
papaparse.js

@ -1189,10 +1189,10 @@ License: MIT
if (!_results) if (!_results)
return; return;
function addHeder(header) function addHeader(header, i)
{ {
if (isFunction(_config.transformHeader)) if (isFunction(_config.transformHeader))
header = _config.transformHeader(header); header = _config.transformHeader(header, i);
_fields.push(header); _fields.push(header);
} }
@ -1200,13 +1200,13 @@ License: MIT
if (Array.isArray(_results.data[0])) if (Array.isArray(_results.data[0]))
{ {
for (var i = 0; needsHeaderRow() && i < _results.data.length; i++) 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); _results.data.splice(0, 1);
} }
// if _results.data[0] is not an array, we are in a step where _results.data is the row. // if _results.data[0] is not an array, we are in a step where _results.data is the row.
else else
_results.data.forEach(addHeder); _results.data.forEach(addHeader);
} }
function shouldApplyDynamicTyping(field) { function shouldApplyDynamicTyping(field) {

Loading…
Cancel
Save