Skip to content

Commit 6b9c3d6

Browse files
Filmbostock
andauthored
explicit error message when the required channel is missing in selectMaxX (#404)
* explicit error message when the required channel is missing in selectMaxX closes #358 * throw new Error * null, not undefined Co-authored-by: Mike Bostock <[email protected]>
1 parent 4dabda0 commit 6b9c3d6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/transforms/select.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,27 @@ export function selectLast(options) {
1010
}
1111

1212
export function selectMinX(options = {}) {
13-
return select(min, options.x, options);
13+
const x = options.x;
14+
if (x == null) throw new Error("missing channel: x");
15+
return select(min, x, options);
1416
}
1517

1618
export function selectMinY(options = {}) {
17-
return select(min, options.y, options);
19+
const y = options.y;
20+
if (y == null) throw new Error("missing channel: y");
21+
return select(min, y, options);
1822
}
1923

2024
export function selectMaxX(options = {}) {
21-
return select(max, options.x, options);
25+
const x = options.x;
26+
if (x == null) throw new Error("missing channel: x");
27+
return select(max, x, options);
2228
}
2329

2430
export function selectMaxY(options = {}) {
25-
return select(max, options.y, options);
31+
const y = options.y;
32+
if (y == null) throw new Error("missing channel: y");
33+
return select(max, y, options);
2634
}
2735

2836
// TODO If the value (for some required channel) is undefined, scan forward?

0 commit comments

Comments
 (0)