summaryrefslogtreecommitdiff
path: root/std/encoding/csv.ts
diff options
context:
space:
mode:
authorMaximilien Mellen <maxmellen0@gmail.com>2020-02-19 21:36:18 +0100
committerGitHub <noreply@github.com>2020-02-19 15:36:18 -0500
commit90125566bbaed8b5c6e55ca8dbc432e3433fb73c (patch)
treebf798a408b26264641260395ce8cfc9d4bb37637 /std/encoding/csv.ts
parent852823fa505d75d61e70e1330bbf366aa248e650 (diff)
Enable TS strict mode by default (#3899)
Fixes #3324 Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
Diffstat (limited to 'std/encoding/csv.ts')
-rw-r--r--std/encoding/csv.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/std/encoding/csv.ts b/std/encoding/csv.ts
index 1314afcaa..12336b10d 100644
--- a/std/encoding/csv.ts
+++ b/std/encoding/csv.ts
@@ -46,7 +46,7 @@ function chkOptions(opt: ReadOptions): void {
}
if (
INVALID_RUNE.includes(opt.comma) ||
- INVALID_RUNE.includes(opt.comment) ||
+ (typeof opt.comment === "string" && INVALID_RUNE.includes(opt.comment)) ||
opt.comma === opt.comment
) {
throw new Error("Invalid Delimiter");
@@ -122,7 +122,7 @@ export async function readMatrix(
}
): Promise<string[][]> {
const result: string[][] = [];
- let _nbFields: number;
+ let _nbFields: number | undefined;
let lineResult: string[];
let first = true;
let lineIndex = 0;
@@ -253,8 +253,10 @@ export async function parse(
});
}
if (opt.parse) {
- assert(opt.parse != null, "opt.parse must be set");
- return r.map((e: string[]): unknown => opt.parse(e));
+ return r.map((e: string[]): unknown => {
+ assert(opt.parse, "opt.parse must be set");
+ return opt.parse(e);
+ });
}
return r;
}