(shape)
| 1 | import {Path} from "d3-path"; |
| 2 | |
| 3 | export function withPath(shape) { |
| 4 | let digits = 3; |
| 5 | |
| 6 | shape.digits = function(_) { |
| 7 | if (!arguments.length) return digits; |
| 8 | if (_ == null) { |
| 9 | digits = null; |
| 10 | } else { |
| 11 | const d = Math.floor(_); |
| 12 | if (!(d >= 0)) throw new RangeError(`invalid digits: ${_}`); |
| 13 | digits = d; |
| 14 | } |
| 15 | return shape; |
| 16 | }; |
| 17 | |
| 18 | return () => new Path(digits); |
| 19 | } |