Skip to content

Commit

Permalink
Revert "Remove ES6 features to allow minifying paparse file"
Browse files Browse the repository at this point in the history
This reverts commit f490abb.
  • Loading branch information
pokoli committed Jan 10, 2025
1 parent 9c42a1e commit d206124
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions papaparse.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,15 +511,15 @@ License: MIT
this.parseChunk = function(chunk, isFakeChunk)
{
// First chunk pre-processing
var skipFirstNLines = parseInt(this._config.skipFirstNLines) || 0;
const skipFirstNLines = parseInt(this._config.skipFirstNLines) || 0;
if (this.isFirstChunk && skipFirstNLines > 0) {
var _newline = this._config.newline;
let _newline = this._config.newline;
if (!_newline) {
var quoteChar = this._config.quoteChar || '"';
const quoteChar = this._config.quoteChar || '"';
_newline = this._handle.guessLineEndings(chunk, quoteChar);
}
var splitChunk = chunk.split(_newline);
chunk = splitChunk.slice(skipFirstNLines).join(_newline);
const splitChunk = chunk.split(_newline);
chunk = [...splitChunk.slice(skipFirstNLines)].join(_newline);
}
if (this.isFirstChunk && isFunction(this._config.beforeFirstChunk))
{
Expand Down Expand Up @@ -1743,26 +1743,26 @@ License: MIT
{
if (config.header && !baseIndex && data.length)
{
var result = data[0];
var headerCount = {}; // To track the count of each base header
var usedHeaders = new Set(result); // To track used headers and avoid duplicates
var duplicateHeaders = false;
const result = data[0];
const headerCount = {}; // To track the count of each base header
const usedHeaders = new Set(result); // To track used headers and avoid duplicates
let duplicateHeaders = false;

for (var i = 0; i < result.length; i++) {
var header = result[i];
for (let i = 0; i < result.length; i++) {
let header = result[i];
if (isFunction(config.transformHeader))
header = config.transformHeader(header, i);

if (!headerCount[header]) {
headerCount[header] = 1;
result[i] = header;
} else {
var newHeader;
var suffixCount = headerCount[header];
let newHeader;
let suffixCount = headerCount[header];

// Find a unique new header
do {
newHeader = header + '_' + suffixCount;
newHeader = `${header}_${suffixCount}`;
suffixCount++;
} while (usedHeaders.has(newHeader));

Expand Down

0 comments on commit d206124

Please sign in to comment.