Skip to content

Commit

Permalink
renamed variables to better reflect their purpose
Browse files Browse the repository at this point in the history
  • Loading branch information
geofflangenderfer committed Feb 6, 2020
1 parent 8a2f74c commit bff93b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/rowSplit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Test delimiters", function () {
assert(returnedDelimiter === ",");
});

it("should accetp an array with potential delimiters", function () {
it("should accept an array with potential delimiters", function () {
var rowStr = "a$b$c";
var returnedDelimiter = getDelimiter(rowStr, { delimiter: [",", ";", "$"] });
assert(returnedDelimiter === '$');
Expand Down
14 changes: 7 additions & 7 deletions src/rowSplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,24 @@ export class RowSplit {
return { cells: row, closed: !inquote };
}
private getDelimiter(fileline: Fileline): string {
let checker;
let possibleDelimiters;
if (this.conv.parseParam.delimiter === "auto") {
checker = defaulDelimiters;
possibleDelimiters = defaulDelimiters;
} else if (this.conv.parseParam.delimiter instanceof Array) {
checker = this.conv.parseParam.delimiter;
possibleDelimiters = this.conv.parseParam.delimiter;
} else {
return this.conv.parseParam.delimiter;
}
let count = 0;
let rtn = ",";
checker.forEach(function (delim) {
let delimiter = ",";
possibleDelimiters.forEach(function (delim) {
const delimCount = fileline.split(delim).length;
if (delimCount > count) {
rtn = delim;
delimiter = delim;
count = delimCount;
}
});
return rtn;
return delimiter;
}
private isQuoteOpen(str: string): boolean {
const quote = this.quote;
Expand Down

0 comments on commit bff93b9

Please sign in to comment.