Skip to content

Commit a409803

Browse files
committed
refactor(csv-parse): websream controller.error without thrown error
1 parent f9aeaa0 commit a409803

2 files changed

Lines changed: 12 additions & 19 deletions

File tree

packages/csv-parse/lib/stream.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@ const parse = (opts) => {
1717
},
1818
transform(chunk) {
1919
const error = api.parse(chunk, false, enqueue, terminate);
20-
2120
if (error) {
2221
controller.error(error);
23-
throw error;
2422
}
2523
},
2624
flush() {
2725
const error = api.parse(undefined, true, enqueue, terminate);
28-
2926
if (error) {
3027
controller.error(error);
31-
throw error;
3228
}
3329
},
3430
},
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,29 @@
1-
import 'should'
2-
import {parse as parseStream} from '../lib/stream.js'
3-
import { CsvError } from '../lib/index.js'
1+
import "should";
2+
import { parse as parseStream } from "../lib/stream.js";
3+
import { CsvError } from "../lib/index.js";
44

5-
describe('API Web Stream', () => {
6-
7-
describe('stream/web/TransformStream', () => {
8-
9-
it('simple parse', async () => {
5+
describe("API Web Stream", () => {
6+
describe("stream/web/TransformStream", () => {
7+
it("simple parse", async () => {
108
const stream = parseStream();
119
const writer = stream.writable.getWriter();
1210
const reader = stream.readable.getReader();
1311
await writer.write(Buffer.from("A,B,C\nD,E,F"));
1412
await writer.close();
1513
await reader.read().should.finally.eql({
1614
done: false,
17-
value: ['A', 'B', 'C'],
15+
value: ["A", "B", "C"],
1816
});
1917
await reader.read().should.finally.eql({
2018
done: false,
21-
value: ['D', 'E', 'F'],
19+
value: ["D", "E", "F"],
2220
});
2321
await reader.read().should.finally.eql({
2422
done: true,
2523
value: undefined,
2624
});
27-
})
28-
25+
});
26+
2927
it("cat error parse", async function () {
3028
const stream = parseStream();
3129
const writer = stream.writable.getWriter();
@@ -40,6 +38,5 @@ describe('API Web Stream', () => {
4038
err.code.should.eql("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH");
4139
}
4240
});
43-
44-
})
45-
})
41+
});
42+
});

0 commit comments

Comments
 (0)