edf2csv 0.5.91 → 0.5.93

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 CHANGED
@@ -3,6 +3,60 @@
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.5.93
7
+
8
+ ### Fixed: the padding after a TAL was counted as an annotation that could not be read
9
+
10
+ ```
11
+ $ edf2csv space-padded.edf --out out
12
+ warning: 2 annotation entries were unreadable and could not be exported.
13
+
14
+ $ cat out/annotations.csv
15
+ onset_s,duration_s,description,record_index
16
+ 0.5,,Lights off,0
17
+ ```
18
+
19
+ The file holds one annotation and it was exported in full. The two "entries" are the spaces
20
+ filling the rest of each record's annotation slot.
21
+
22
+ EDF+ pads that slot with `0x00`, which the decoder skips because NUL is also what ends one TAL
23
+ and starts the next. Writers pad with spaces, and a run of spaces after the last TAL is a
24
+ non-empty chunk that does not begin with a sign — so it took the malformed branch. Under
25
+ `--strict` that is a failed run over the whitespace at the end of a slot, on a file that lost
26
+ nothing.
27
+
28
+ Whitespace-only chunks are padding now — space, tab, CR, LF and NUL. A chunk of anything else
29
+ that does not parse is still counted and still reported, which is the case the warning exists
30
+ for.
31
+
32
+ ## 0.5.92
33
+
34
+ ### Fixed: `--info` redirected into a full filesystem wrote nothing and exited 0
35
+
36
+ ```
37
+ $ edf2csv wide.edf --info > desc.txt
38
+ $ echo $?
39
+ 0
40
+ $ wc -c desc.txt
41
+ 0 desc.txt
42
+ ```
43
+
44
+ A conversion audits what actually reached stdout — that is what 0.5.82 and the disk-image tests
45
+ are about. `--info` wrote its description with `process.stdout.write` and looked at nothing, so
46
+ a run that produced no description at all reported success. `edf2csv rec.edf --info > desc.txt`
47
+ in a script is exactly how someone captures one.
48
+
49
+ A description is usually a few hundred bytes, which is why this went unnoticed; a 900-channel
50
+ recording's is 58 KB, and no destination is guaranteed to have that.
51
+
52
+ It uses the same audit now, so it exits 1 and names the cause. That audit declines anything
53
+ that is not a regular file, so a pipe and a terminal are untouched and `--info | head` still
54
+ exits 0.
55
+
56
+ The test took two attempts: filling the volume completely means the shell cannot create the
57
+ redirect target and the tool never runs, which is what the first one measured. It leaves twenty
58
+ kilobytes and writes 58 into it.
59
+
6
60
  ## 0.5.91
7
61
 
8
62
  ### Fixed: `--start` at the recording's exact length was accepted when the length was a product
package/dist/cli.js CHANGED
@@ -18,7 +18,7 @@ import process from 'node:process';
18
18
  import { EdfError } from './edf/errors.js';
19
19
  import { EdfFile } from './edf/reader.js';
20
20
  import { buildPlan, withoutFileRateWarning } from './convert/plan.js';
21
- import { ConversionError, USAGE_ERROR_CODES, convert, defaultOutputDir, durationDiagnostics, stdoutRefusal, } from './convert/run.js';
21
+ import { ConversionError, USAGE_ERROR_CODES, auditStdout, convert, defaultOutputDir, durationDiagnostics, stdoutRefusal, } from './convert/run.js';
22
22
  import { ChannelSelectionError } from './convert/channels.js';
23
23
  // Shared with the library so a bad option is the same error whichever way it arrived.
24
24
  import { OptionError } from './convert/options.js';
@@ -709,7 +709,21 @@ async function showInfo(input, shared, asJson, jsonIndent, batch = false, toStdo
709
709
  });
710
710
  }
711
711
  }
712
- process.stdout.write(asJson ? `${infoJson(file, plan, jsonIndent)}\n` : `${formatInfo(file, plan)}\n`);
712
+ /*
713
+ Checked, like a conversion's stdout is.
714
+
715
+ This wrote and looked at nothing, so `--info > desc.txt` into a filesystem with no room
716
+ produced a zero-byte file and exited 0. The same audit the `--stdout` path uses: it
717
+ declines anything that is not a regular file, so a pipe or a terminal is unaffected, and
718
+ `--info | head` keeps exiting 0.
719
+ */
720
+ const audit = auditStdout();
721
+ const description = asJson
722
+ ? `${infoJson(file, plan, jsonIndent)}\n`
723
+ : `${formatInfo(file, plan)}\n`;
724
+ process.stdout.write(description);
725
+ audit?.count(Buffer.byteLength(description));
726
+ audit?.verify();
713
727
  // Under --json the warnings travel inside the document, exactly as they do for a
714
728
  // conversion, so stderr stays empty and the whole result is one parseable thing.
715
729
  const diagnostics = [...withoutFileRateWarning(file.diagnostics), ...plan.diagnostics];