@ezs/basics 1.23.3 → 1.23.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/lib/csv-parse.js +12 -7
- package/lib/txt-concat.js +8 -1
- package/lib/txt-parse.js +8 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.23.5](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.4...@ezs/basics@1.23.5) (2023-03-24)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* 🐛 multi bytes in txtconcat ([7c705fa](https://github.com/Inist-CNRS/ezs/commit/7c705facc1378fae709bbae6a2b416b059e81731))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [1.23.4](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.3...@ezs/basics@1.23.4) (2023-03-24)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* 🐛 CSV.stream not support multi-byte utf8 characters ([1e15c9c](https://github.com/Inist-CNRS/ezs/commit/1e15c9c9061f8927d67bec36577e7c0d5bb15d8e))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [1.23.3](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.2...@ezs/basics@1.23.3) (2023-02-27)
|
|
7
29
|
|
|
8
30
|
|
package/lib/csv-parse.js
CHANGED
|
@@ -9,25 +9,30 @@ var _csvString = _interopRequireDefault(require("csv-string"));
|
|
|
9
9
|
|
|
10
10
|
var _streamWrite = _interopRequireDefault(require("stream-write"));
|
|
11
11
|
|
|
12
|
+
var _string_decoder = require("string_decoder");
|
|
13
|
+
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
function CSVParse(data, feed) {
|
|
15
17
|
const separator = this.getParam('separator');
|
|
16
18
|
const quote = this.getParam('quote');
|
|
17
19
|
|
|
18
|
-
if (!this.
|
|
19
|
-
this.
|
|
20
|
+
if (!this.decoder) {
|
|
21
|
+
this.decoder = new _string_decoder.StringDecoder('utf8');
|
|
22
|
+
this.input = _csvString.default.createStream({
|
|
20
23
|
separator,
|
|
21
24
|
quote
|
|
22
25
|
});
|
|
23
|
-
this.
|
|
26
|
+
this.whenFinish = feed.flow(this.input);
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
29
|
+
if (this.isLast()) {
|
|
30
|
+
this.decoder.end();
|
|
31
|
+
this.whenFinish.finally(() => feed.close());
|
|
32
|
+
return this.input.end();
|
|
30
33
|
}
|
|
34
|
+
|
|
35
|
+
(0, _streamWrite.default)(this.input, Buffer.isBuffer(data) ? this.decoder.write(data) : data, () => feed.end());
|
|
31
36
|
}
|
|
32
37
|
/**
|
|
33
38
|
* Take `String` and parse it as CSV to generate arrays.
|
package/lib/txt-concat.js
CHANGED
|
@@ -5,16 +5,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _string_decoder = require("string_decoder");
|
|
9
|
+
|
|
8
10
|
function TXTConcat(data, feed) {
|
|
11
|
+
if (!this.decoder) {
|
|
12
|
+
this.decoder = new _string_decoder.StringDecoder('utf8');
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
if (this.buffer === undefined) {
|
|
10
16
|
this.buffer = '';
|
|
11
17
|
}
|
|
12
18
|
|
|
13
19
|
if (this.isLast()) {
|
|
20
|
+
this.decoder.end();
|
|
14
21
|
feed.send(this.buffer);
|
|
15
22
|
feed.close();
|
|
16
23
|
} else {
|
|
17
|
-
this.buffer = this.buffer.concat(data);
|
|
24
|
+
this.buffer = this.buffer.concat(Buffer.isBuffer(data) ? this.decoder.write(data) : data);
|
|
18
25
|
feed.end();
|
|
19
26
|
}
|
|
20
27
|
}
|
package/lib/txt-parse.js
CHANGED
|
@@ -5,8 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _string_decoder = require("string_decoder");
|
|
9
|
+
|
|
8
10
|
function TXTParse(data, feed) {
|
|
11
|
+
if (!this.decoder) {
|
|
12
|
+
this.decoder = new _string_decoder.StringDecoder('utf8');
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
if (this.isLast()) {
|
|
16
|
+
this.decoder.end();
|
|
10
17
|
return feed.end();
|
|
11
18
|
}
|
|
12
19
|
|
|
@@ -23,7 +30,7 @@ function TXTParse(data, feed) {
|
|
|
23
30
|
let lines;
|
|
24
31
|
|
|
25
32
|
if (Buffer.isBuffer(data)) {
|
|
26
|
-
lines =
|
|
33
|
+
lines = this.decoder.write(data).split(separator);
|
|
27
34
|
} else if (typeof data === 'string') {
|
|
28
35
|
lines = data.split(separator);
|
|
29
36
|
} else {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ezs/basics",
|
|
3
3
|
"description": "Basics statements for EZS",
|
|
4
|
-
"version": "1.23.
|
|
4
|
+
"version": "1.23.5",
|
|
5
5
|
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
|
|
6
6
|
"bugs": "https://github.com/Inist-CNRS/ezs/issues",
|
|
7
7
|
"dependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"directories": {
|
|
40
40
|
"test": "test"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "bd9ad8cea9ee24f9c2c8cbc20c0ec09fbbc1d8ed",
|
|
43
43
|
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
|
|
44
44
|
"keywords": [
|
|
45
45
|
"ezs"
|