edf2csv 0.2.29 → 0.2.30
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 +28 -0
- package/dist/format/csv.d.ts.map +1 -1
- package/dist/format/csv.js +27 -0
- package/dist/format/csv.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
Notable changes to edf2csv. Versions follow [semantic versioning](https://semver.org); while the
|
|
4
4
|
major version is 0, a minor bump may contain breaking changes.
|
|
5
5
|
|
|
6
|
+
## 0.2.30
|
|
7
|
+
|
|
8
|
+
### Fixed: `--stdout` piped into `head` reported a write failure
|
|
9
|
+
|
|
10
|
+
The most ordinary thing you would do with `--stdout` broke it:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
$ edf2csv big.edf --stdout | head -1
|
|
14
|
+
time_s,ch1
|
|
15
|
+
error: Writing to stdout failed: write EPIPE
|
|
16
|
+
The files written so far are incomplete and should not be used. Free up space or
|
|
17
|
+
choose another destination with --out, then run the conversion again.
|
|
18
|
+
exit 1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Three things wrong at once — exit 1 for a routine shell idiom, a claim about files that were never
|
|
22
|
+
written, and advice about disk space and `--out` that had nothing to do with it.
|
|
23
|
+
|
|
24
|
+
`EPIPE` is the reader hanging up, not a write failure, and a file stream cannot raise it. The
|
|
25
|
+
buffered writer now treats it as a clean end: writing stops, the run exits 0, and whatever the reader
|
|
26
|
+
did take is intact. Genuine write failures — a full disk, an unwritable path — are unaffected and
|
|
27
|
+
still exit 1 with their message.
|
|
28
|
+
|
|
29
|
+
It needed handling in two places. The writer's `error` listener catches a pipe that closes during a
|
|
30
|
+
write; a separate listener, registered only while waiting for `drain`, sees one that closes while the
|
|
31
|
+
consumer is behind. Only the first was obvious, and a long conversion is precisely the case that
|
|
32
|
+
reaches the second.
|
|
33
|
+
|
|
6
34
|
## 0.2.29
|
|
7
35
|
|
|
8
36
|
### Docs: the scripting advice caught up with `--strict`, `--info --json` and `--stdout`
|
package/dist/format/csv.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/format/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEvD;AAED;;;;;GAKG;AACH,qBAAa,kBAAkB;;
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/format/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAQ5C,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEvD;AAED;;;;;GAKG;AACH,qBAAa,kBAAkB;;gBAWjB,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAE,MAAgC;IAwBzE,8EAA8E;IAC9E,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK5B,qEAAqE;IAC/D,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAsD5B,gDAAgD;IAC1C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAe1B,oEAAoE;IACpE,OAAO,IAAI,IAAI;CAOhB"}
|
package/dist/format/csv.js
CHANGED
|
@@ -34,6 +34,8 @@ export class BufferedLineWriter {
|
|
|
34
34
|
#threshold;
|
|
35
35
|
#bytesWritten = 0;
|
|
36
36
|
#ended = false;
|
|
37
|
+
/** The reader closed the pipe; there is nowhere left to write, but this is not a failure. */
|
|
38
|
+
#hungUp = false;
|
|
37
39
|
#failure = null;
|
|
38
40
|
constructor(stream, threshold = DEFAULT_FLUSH_THRESHOLD) {
|
|
39
41
|
this.#stream = stream;
|
|
@@ -42,6 +44,19 @@ export class BufferedLineWriter {
|
|
|
42
44
|
// process down with a raw stack trace. Capturing the error here lets the next
|
|
43
45
|
// flush surface it as a normal failure with a usable message.
|
|
44
46
|
this.#stream.on('error', (error) => {
|
|
47
|
+
/*
|
|
48
|
+
EPIPE is the reader hanging up, not a write failure.
|
|
49
|
+
|
|
50
|
+
`edf2csv recording.edf --stdout | head -1` closes the pipe while the conversion is
|
|
51
|
+
still writing, and treating that as an error produced exit 1 and a message about
|
|
52
|
+
files that do not exist and disk space that is not the problem. A file stream
|
|
53
|
+
cannot raise EPIPE, so this only ever means "the consumer stopped reading", which
|
|
54
|
+
is what a shell pipeline does routinely and on purpose.
|
|
55
|
+
*/
|
|
56
|
+
if (error.code === 'EPIPE') {
|
|
57
|
+
this.#hungUp = true;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
45
60
|
this.#failure ??= error;
|
|
46
61
|
});
|
|
47
62
|
}
|
|
@@ -65,6 +80,10 @@ export class BufferedLineWriter {
|
|
|
65
80
|
async flush() {
|
|
66
81
|
if (this.#failure)
|
|
67
82
|
throw this.#failure;
|
|
83
|
+
// The reader hung up (see the EPIPE note above); there is nowhere left to write.
|
|
84
|
+
// Deliberately not `#ended`, which end() sets before its own final flush.
|
|
85
|
+
if (this.#hungUp)
|
|
86
|
+
return;
|
|
68
87
|
if (this.#parts.length === 0)
|
|
69
88
|
return;
|
|
70
89
|
const chunk = this.#parts.join('');
|
|
@@ -93,6 +112,14 @@ export class BufferedLineWriter {
|
|
|
93
112
|
};
|
|
94
113
|
const onError = (error) => {
|
|
95
114
|
cleanup();
|
|
115
|
+
// A pipe closing while we wait for drain is the same benign hang-up as one
|
|
116
|
+
// closing during a write, and has to be handled here too: this listener is
|
|
117
|
+
// registered for the duration of the wait and sees the error first.
|
|
118
|
+
if (error.code === 'EPIPE') {
|
|
119
|
+
this.#hungUp = true;
|
|
120
|
+
resolve();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
96
123
|
reject(error);
|
|
97
124
|
};
|
|
98
125
|
const onClose = () => {
|
package/dist/format/csv.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.js","sourceRoot":"","sources":["../../src/format/csv.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAEnC,wDAAwD;AACxD,MAAM,uBAAuB,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ;AAEjD,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC7C,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,KAAwB;IAC7C,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,kBAAkB;IAC7B,OAAO,CAAW;IAClB,MAAM,GAAa,EAAE,CAAC;IACtB,QAAQ,GAAG,CAAC,CAAC;IACb,UAAU,CAAS;IACnB,aAAa,GAAG,CAAC,CAAC;IAClB,M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AI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edf2csv",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.30",
|
|
4
4
|
"description": "Convert EDF, EDF+ and BDF biosignal recordings (European Data Format) to CSV from the command line. Local, streaming, and never resamples or alters units.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"edf",
|