Skip to content

Commit

Permalink
Merge pull request #361 from geofflangenderfer/master
Browse files Browse the repository at this point in the history
renamed variables to better reflect their purpose
  • Loading branch information
jeremyrajan authored Apr 8, 2020
2 parents 02f4cfb + 917e3b0 commit 0b9f177
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 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
16 changes: 8 additions & 8 deletions src/rowSplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Fileline } from "./fileline";
import getEol from "./getEol";
import { filterArray, trimLeft, trimRight } from "./util";

const defaulDelimiters = [",", "|", "\t", ";", ":"];
const defaultDelimiters = [",", "|", "\t", ";", ":"];
export class RowSplit {
private quote: string;
private trim: boolean;
Expand Down 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 = defaultDelimiters;
} 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 0b9f177

Please sign in to comment.