// Given something array like (or null), returns something that is strictly an | |
// array. This is used to ensure that array-like objects passed to d3.selectAll | |
// or selection.selectAll are converted into proper arrays when creating a | |
// selection; we don’t ever want to create a selection backed by a live | |
// HTMLCollection or NodeList. However, note that selection.selectAll will use a | |
// static NodeList as a group, since it safely derived from querySelectorAll. | |
export default function array(x) { | |
return x == null ? [] : Array.isArray(x) ? x : Array.from(x); | |
} | |