Skip to content

Commit d8bf4fd

Browse files
committed
feat(csv-parse): null comment_no_infix type
1 parent b9ac1f0 commit d8bf4fd

File tree

3 files changed

+60
-53
lines changed

3 files changed

+60
-53
lines changed

packages/csv-parse/lib/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export interface Options<T = string[]> {
114114
* defined in the middle of the line are not interpreted as such. The
115115
* option require the activation of comments.
116116
*/
117-
comment_no_infix?: boolean;
117+
comment_no_infix?: boolean | null;
118118
/**
119119
* Set the field delimiter. One character only, defaults to comma.
120120
*/

packages/csv-parse/test/option.comment_no_infix.js

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { parse } from "../lib/index.js";
33

44
describe("Option `comment_no_infix`", function () {
55
it("validation", function () {
6-
parse("", { comment_no_infix: undefined }, () => {});
7-
parse("", { comment_no_infix: null }, () => {});
8-
parse("", { comment_no_infix: false }, () => {});
9-
parse("", { comment_no_infix: true }, () => {});
106
(() => {
117
parse("", { comment_no_infix: "" }, () => {});
128
}).should.throw({
@@ -22,52 +18,4 @@ describe("Option `comment_no_infix`", function () {
2218
code: "CSV_INVALID_OPTION_COMMENT",
2319
});
2420
});
25-
26-
it("with `true`, field starting with comment", function (next) {
27-
parse(
28-
"a,#,c",
29-
{
30-
comment: "#",
31-
comment_no_infix: true,
32-
},
33-
(err, records) => {
34-
if (!err) {
35-
records.should.eql([["a", "#", "c"]]);
36-
}
37-
next(err);
38-
},
39-
);
40-
});
41-
42-
it("with `true`, field not starting with comment", function (next) {
43-
parse(
44-
"a,b#,c",
45-
{
46-
comment: "#",
47-
comment_no_infix: true,
48-
},
49-
(err, records) => {
50-
if (!err) {
51-
records.should.eql([["a", "b#", "c"]]);
52-
}
53-
next(err);
54-
},
55-
);
56-
});
57-
58-
it("with `false`", function (next) {
59-
parse(
60-
"a,b#,c",
61-
{
62-
comment: "#",
63-
comment_no_infix: false,
64-
},
65-
(err, records) => {
66-
if (!err) {
67-
records.should.eql([["a", "b"]]);
68-
}
69-
next(err);
70-
},
71-
);
72-
});
7321
});
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import "should";
2+
import { parse } from "../lib/index.js";
3+
4+
describe("Option `comment_no_infix`", function () {
5+
it("validation", function () {
6+
parse("", { comment_no_infix: undefined }, () => {});
7+
parse("", { comment_no_infix: null }, () => {});
8+
parse("", { comment_no_infix: false }, () => {});
9+
parse("", { comment_no_infix: true }, () => {});
10+
});
11+
12+
it("with `true`, field starting with comment", function (next) {
13+
parse(
14+
"a,#,c",
15+
{
16+
comment: "#",
17+
comment_no_infix: true,
18+
},
19+
(err, records) => {
20+
if (!err) {
21+
records.should.eql([["a", "#", "c"]]);
22+
}
23+
next(err);
24+
},
25+
);
26+
});
27+
28+
it("with `true`, field not starting with comment", function (next) {
29+
parse(
30+
"a,b#,c",
31+
{
32+
comment: "#",
33+
comment_no_infix: true,
34+
},
35+
(err, records) => {
36+
if (!err) {
37+
records.should.eql([["a", "b#", "c"]]);
38+
}
39+
next(err);
40+
},
41+
);
42+
});
43+
44+
it("with `false`", function (next) {
45+
parse(
46+
"a,b#,c",
47+
{
48+
comment: "#",
49+
comment_no_infix: false,
50+
},
51+
(err, records) => {
52+
if (!err) {
53+
records.should.eql([["a", "b"]]);
54+
}
55+
next(err);
56+
},
57+
);
58+
});
59+
});

0 commit comments

Comments
 (0)