edfcore 0.6.93 → 0.6.94
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/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/sample-grid.d.ts.map +1 -1
- package/dist/sample-grid.js +3 -1
- package/dist/sample-grid.js.map +1 -1
- package/dist/sample-locate.d.ts.map +1 -1
- package/dist/sample-locate.js +5 -2
- package/dist/sample-locate.js.map +1 -1
- package/dist/text/describe.d.ts +21 -0
- package/dist/text/describe.d.ts.map +1 -0
- package/dist/text/describe.js +35 -0
- package/dist/text/describe.js.map +1 -0
- package/docs/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/constants.ts +1 -1
- package/src/sample-grid.ts +3 -1
- package/src/sample-locate.ts +5 -2
- package/src/text/describe.ts +30 -0
package/dist/constants.d.ts
CHANGED
|
@@ -109,5 +109,5 @@ export declare const SIGNAL_FIELD_BLOCK_OFFSETS: {
|
|
|
109
109
|
readonly reserved: 224;
|
|
110
110
|
};
|
|
111
111
|
/** Published package version. Kept in sync with package.json by a test. */
|
|
112
|
-
export declare const VERSION = "0.6.
|
|
112
|
+
export declare const VERSION = "0.6.94";
|
|
113
113
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;
|
|
1
|
+
{"version":3,"file":"sample-grid.d.ts","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAKH,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAgC/D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,mBAAmB,EAAE,MAAM,GAC1B,iBAAiB,CAoBnB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAiBR;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAKR"}
|
package/dist/sample-grid.js
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
*/
|
|
43
43
|
import { TICKS_PER_SECOND } from './constants.js';
|
|
44
44
|
import { secondsToTicks } from './tal/ticks.js';
|
|
45
|
+
import { describeValue } from './text/describe.js';
|
|
45
46
|
function assertGrid(signal, recordDurationTicks) {
|
|
46
47
|
if (signal.kind === 'annotations') {
|
|
47
48
|
throw new RangeError(`signal ${signal.index} (${JSON.stringify(signal.label)}) is an annotations channel, ` +
|
|
@@ -107,7 +108,8 @@ export function gridSampleIndexAt(signal, seconds, recordDurationTicks) {
|
|
|
107
108
|
export function gridSampleStartTicks(signal, sampleIndex, recordDurationTicks) {
|
|
108
109
|
assertGrid(signal, recordDurationTicks);
|
|
109
110
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
110
|
-
throw new RangeError(`gridSampleStartTicks(): sampleIndex must be a whole number, received
|
|
111
|
+
throw new RangeError(`gridSampleStartTicks(): sampleIndex must be a whole number, received ` +
|
|
112
|
+
`${describeValue(sampleIndex)}. ` +
|
|
111
113
|
"Next: pass a whole index; this family measures the signal's own grid, so a fractional " +
|
|
112
114
|
'one has no position on it.');
|
|
113
115
|
}
|
package/dist/sample-grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-grid.js","sourceRoot":"","sources":["../src/sample-grid.ts"],"names":[],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,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,mBAAmB,CAAC;IAC5D,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;IACvC,6FAA6F;IAC7F,6DAA6D;IAC7D,IAAI,SAAS,GAAG,SAAS,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAC;IAClD,OAAO,SAAS,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AACnD,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,WAAmB,EACnB,mBAA2B;IAE3B,MAAM,KAAK,GAAG,oBAAoB,CAAC,MAAM,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC;IAC7E,MAAM,KAAK,GAAG,KAAK,GAAG,gBAAgB,CAAC;IACvC,MAAM,SAAS,GAAG,KAAK,GAAG,gBAAgB,CAAC;IAC3C,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;
|
|
1
|
+
{"version":3,"file":"sample-locate.d.ts","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAMH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAyB,MAAM,YAAY,CAAC;AA2FzF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,SAAS,CAgE/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAwCR;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
|
package/dist/sample-locate.js
CHANGED
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import { EdfChannelNotFoundError } from './errors.js';
|
|
35
35
|
import { segmentAt } from './record-index.js';
|
|
36
36
|
import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
|
|
37
|
+
import { describeValue } from './text/describe.js';
|
|
37
38
|
/**
|
|
38
39
|
* Shared by `sampleAt` and `sampleStartTicksOf`, so the messages name NO function — the rule
|
|
39
40
|
* `envelope.ts` states for its own shared helpers. `sampleStartSecondsOf` is a one-line delegation
|
|
@@ -124,7 +125,8 @@ function probedIndexNeedsScan(recording) {
|
|
|
124
125
|
export function sampleAt(recording, signalIndex, seconds) {
|
|
125
126
|
const signal = resolveSignal(recording, signalIndex);
|
|
126
127
|
if (!Number.isFinite(seconds)) {
|
|
127
|
-
throw new RangeError(`sampleAt(): seconds must be a finite number, received ${seconds}.
|
|
128
|
+
throw new RangeError(`sampleAt(): seconds must be a finite number, received ${describeValue(seconds)}. ` +
|
|
129
|
+
`Next: pass a time on ` +
|
|
128
130
|
'the recording axis, where t = 0 is the start of record 0.');
|
|
129
131
|
}
|
|
130
132
|
const duration = recording.header.recordDurationTicks;
|
|
@@ -193,7 +195,8 @@ export function sampleAt(recording, signalIndex, seconds) {
|
|
|
193
195
|
export function sampleStartTicksOf(recording, signalIndex, sampleIndex) {
|
|
194
196
|
const signal = resolveSignal(recording, signalIndex);
|
|
195
197
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
196
|
-
throw new RangeError(`sampleIndex must be a whole number, received ${sampleIndex}.
|
|
198
|
+
throw new RangeError(`sampleIndex must be a whole number, received ${describeValue(sampleIndex)}. ` +
|
|
199
|
+
`Next: index by ` +
|
|
197
200
|
'samplesPerRecord rather than deriving one from a float sampleRateHz.');
|
|
198
201
|
}
|
|
199
202
|
const perRecord = signal.samplesPerRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sample-locate.js","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sample-locate.js","sourceRoot":"","sources":["../src/sample-locate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,SAAS,aAAa,CAAC,SAAuB,EAAE,WAAmB;IACjE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,uBAAuB,CAC/B,eAAe,WAAW,kBAAkB;YAC1C,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAA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rC,GAAG,SAAS,CAAC,MAAM,CAAC,WAAW,GAAG,SAAS,mBAAmB,WAAW,QAAQ;YACjF,0DAA0D,CAC7D,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,oBAAoB,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9E,MAAM,IAAI,UAAU,CAClB,qEAAqE;YACnE,0FAA0F;YAC1F,qCAAqC,CACxC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;IAChG,MAAM,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAC;IACpC,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC7C,yCAAyC;IACzC,OAAO,KAAK,GAAG,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAC/E,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,oBAAoB,CAClC,SAAuB,EACvB,WAAmB,EACnB,WAAmB;IAEnB,OAAO,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rejected value, said in a way that cannot read as an accepted one.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Every numeric guard in this package printed the offending value with `${value}`, which is right
|
|
7
|
+
* for a number and wrong for everything else. `Number.isSafeInteger('0')` is false, so the string
|
|
8
|
+
* `'0'` was rejected and then reported as "must be a whole number, received 0" — a sentence whose
|
|
9
|
+
* rule the printed value satisfies. A reader who trusts the message looks past the argument.
|
|
10
|
+
*
|
|
11
|
+
* A BigInt is the case that costs the most. Every instant and every span edfcore hands out is
|
|
12
|
+
* ticks, so passing one back where a number belongs is a mistake the API's own shape invites, and
|
|
13
|
+
* `received 10000000` reads as a plausible value rather than as one out by ten million.
|
|
14
|
+
*
|
|
15
|
+
* Numbers keep their bare spelling, so `NaN`, `Infinity` and a real out-of-range integer say
|
|
16
|
+
* exactly what they said before. This helper only exists for the values that are not numbers at
|
|
17
|
+
* all (0.6.94).
|
|
18
|
+
*/
|
|
19
|
+
/** The value as a phrase that fits after "received" or "was given". Never a value's contents. */
|
|
20
|
+
export declare function describeValue(value: unknown): string;
|
|
21
|
+
//# sourceMappingURL=describe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.d.ts","sourceRoot":"","sources":["../../src/text/describe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASpD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rejected value, said in a way that cannot read as an accepted one.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Every numeric guard in this package printed the offending value with `${value}`, which is right
|
|
7
|
+
* for a number and wrong for everything else. `Number.isSafeInteger('0')` is false, so the string
|
|
8
|
+
* `'0'` was rejected and then reported as "must be a whole number, received 0" — a sentence whose
|
|
9
|
+
* rule the printed value satisfies. A reader who trusts the message looks past the argument.
|
|
10
|
+
*
|
|
11
|
+
* A BigInt is the case that costs the most. Every instant and every span edfcore hands out is
|
|
12
|
+
* ticks, so passing one back where a number belongs is a mistake the API's own shape invites, and
|
|
13
|
+
* `received 10000000` reads as a plausible value rather than as one out by ten million.
|
|
14
|
+
*
|
|
15
|
+
* Numbers keep their bare spelling, so `NaN`, `Infinity` and a real out-of-range integer say
|
|
16
|
+
* exactly what they said before. This helper only exists for the values that are not numbers at
|
|
17
|
+
* all (0.6.94).
|
|
18
|
+
*/
|
|
19
|
+
/** The value as a phrase that fits after "received" or "was given". Never a value's contents. */
|
|
20
|
+
export function describeValue(value) {
|
|
21
|
+
if (typeof value === 'number')
|
|
22
|
+
return String(value);
|
|
23
|
+
if (typeof value === 'bigint')
|
|
24
|
+
return `the BigInt ${value}n`;
|
|
25
|
+
if (typeof value === 'string')
|
|
26
|
+
return `the string ${JSON.stringify(value)}`;
|
|
27
|
+
if (value === null)
|
|
28
|
+
return 'null';
|
|
29
|
+
if (value === undefined)
|
|
30
|
+
return 'undefined';
|
|
31
|
+
// `an object` covers an array too: a reader who passed one knows which they passed, and printing
|
|
32
|
+
// its contents is how a 512-signal selection ends up on one line behind `edfcore: `.
|
|
33
|
+
return typeof value === 'object' ? 'an object' : `a ${typeof value}`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=describe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../src/text/describe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,cAAc,KAAK,GAAG,CAAC;IAC7D,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,cAAc,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;IAC5E,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAClC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC;IAC5C,iGAAiG;IACjG,qFAAqF;IACrF,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK,EAAE,CAAC;AACvE,CAAC"}
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ alone does not tell you whether you were affected.
|
|
|
6
6
|
edfcore is pre-1.0. Patch releases have carried behaviour changes where the old behaviour was a
|
|
7
7
|
defect; those are called out below.
|
|
8
8
|
|
|
9
|
+
## 0.6.94
|
|
10
|
+
|
|
11
|
+
- **Changed** what the sample family's numeric guards print when the value is not a number at all —
|
|
12
|
+
`gridSampleStartTicks`, `gridSampleStartSeconds`, `sampleStartTicksOf`, `sampleStartSecondsOf` and
|
|
13
|
+
`sampleAt`.
|
|
14
|
+
- `Number.isSafeInteger('0')` is false, so the string was rejected correctly and then printed with
|
|
15
|
+
`${value}`: "sampleIndex must be a whole number, received 0". 0 is a whole number. A reader who
|
|
16
|
+
trusts a message describing a rule its own evidence satisfies looks past the argument.
|
|
17
|
+
- A BigInt costs the most, for the reason 0.6.92 gives about the time layer: every instant and every
|
|
18
|
+
span edfcore hands out is ticks, so `received 10000000` reads as a plausible sample index rather
|
|
19
|
+
than as one out by ten million.
|
|
20
|
+
- Numbers keep their bare spelling, so `NaN`, `Infinity` and a real fractional index say exactly
|
|
21
|
+
what they said before.
|
|
22
|
+
|
|
9
23
|
## 0.6.93
|
|
10
24
|
|
|
11
25
|
- **Changed** what `getSignal(header, 1.5)` says. `header.signals[1.5]` is `undefined`, so a
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
package/src/sample-grid.ts
CHANGED
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
import { TICKS_PER_SECOND } from './constants.js';
|
|
45
45
|
import { secondsToTicks } from './tal/ticks.js';
|
|
46
|
+
import { describeValue } from './text/describe.js';
|
|
46
47
|
import type { EdfSampleLocation, EdfSignal } from './types.js';
|
|
47
48
|
|
|
48
49
|
function assertGrid(signal: EdfSignal, recordDurationTicks: bigint): void {
|
|
@@ -129,7 +130,8 @@ export function gridSampleStartTicks(
|
|
|
129
130
|
assertGrid(signal, recordDurationTicks);
|
|
130
131
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
131
132
|
throw new RangeError(
|
|
132
|
-
`gridSampleStartTicks(): sampleIndex must be a whole number, received
|
|
133
|
+
`gridSampleStartTicks(): sampleIndex must be a whole number, received ` +
|
|
134
|
+
`${describeValue(sampleIndex)}. ` +
|
|
133
135
|
"Next: pass a whole index; this family measures the signal's own grid, so a fractional " +
|
|
134
136
|
'one has no position on it.',
|
|
135
137
|
);
|
package/src/sample-locate.ts
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
import { EdfChannelNotFoundError } from './errors.js';
|
|
36
36
|
import { segmentAt } from './record-index.js';
|
|
37
37
|
import { floorDiv, secondsToTicks, ticksToSeconds } from './tal/ticks.js';
|
|
38
|
+
import { describeValue } from './text/describe.js';
|
|
38
39
|
import type { EdfRecording, EdfSampleLocation, EdfSegment, EdfSignal } from './types.js';
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -146,7 +147,8 @@ export function sampleAt(
|
|
|
146
147
|
const signal = resolveSignal(recording, signalIndex);
|
|
147
148
|
if (!Number.isFinite(seconds)) {
|
|
148
149
|
throw new RangeError(
|
|
149
|
-
`sampleAt(): seconds must be a finite number, received ${seconds}.
|
|
150
|
+
`sampleAt(): seconds must be a finite number, received ${describeValue(seconds)}. ` +
|
|
151
|
+
`Next: pass a time on ` +
|
|
150
152
|
'the recording axis, where t = 0 is the start of record 0.',
|
|
151
153
|
);
|
|
152
154
|
}
|
|
@@ -227,7 +229,8 @@ export function sampleStartTicksOf(
|
|
|
227
229
|
const signal = resolveSignal(recording, signalIndex);
|
|
228
230
|
if (!Number.isSafeInteger(sampleIndex)) {
|
|
229
231
|
throw new RangeError(
|
|
230
|
-
`sampleIndex must be a whole number, received ${sampleIndex}.
|
|
232
|
+
`sampleIndex must be a whole number, received ${describeValue(sampleIndex)}. ` +
|
|
233
|
+
`Next: index by ` +
|
|
231
234
|
'samplesPerRecord rather than deriving one from a float sampleRateHz.',
|
|
232
235
|
);
|
|
233
236
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rejected value, said in a way that cannot read as an accepted one.
|
|
3
|
+
*
|
|
4
|
+
* Layer 1. Imports nothing.
|
|
5
|
+
*
|
|
6
|
+
* Every numeric guard in this package printed the offending value with `${value}`, which is right
|
|
7
|
+
* for a number and wrong for everything else. `Number.isSafeInteger('0')` is false, so the string
|
|
8
|
+
* `'0'` was rejected and then reported as "must be a whole number, received 0" — a sentence whose
|
|
9
|
+
* rule the printed value satisfies. A reader who trusts the message looks past the argument.
|
|
10
|
+
*
|
|
11
|
+
* A BigInt is the case that costs the most. Every instant and every span edfcore hands out is
|
|
12
|
+
* ticks, so passing one back where a number belongs is a mistake the API's own shape invites, and
|
|
13
|
+
* `received 10000000` reads as a plausible value rather than as one out by ten million.
|
|
14
|
+
*
|
|
15
|
+
* Numbers keep their bare spelling, so `NaN`, `Infinity` and a real out-of-range integer say
|
|
16
|
+
* exactly what they said before. This helper only exists for the values that are not numbers at
|
|
17
|
+
* all (0.6.94).
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/** The value as a phrase that fits after "received" or "was given". Never a value's contents. */
|
|
21
|
+
export function describeValue(value: unknown): string {
|
|
22
|
+
if (typeof value === 'number') return String(value);
|
|
23
|
+
if (typeof value === 'bigint') return `the BigInt ${value}n`;
|
|
24
|
+
if (typeof value === 'string') return `the string ${JSON.stringify(value)}`;
|
|
25
|
+
if (value === null) return 'null';
|
|
26
|
+
if (value === undefined) return 'undefined';
|
|
27
|
+
// `an object` covers an array too: a reader who passed one knows which they passed, and printing
|
|
28
|
+
// its contents is how a 512-signal selection ends up on one line behind `edfcore: `.
|
|
29
|
+
return typeof value === 'object' ? 'an object' : `a ${typeof value}`;
|
|
30
|
+
}
|