You can use your solution by changing the prototype of choosing d3 (unlike the prototype of an object, I don’t think it could be considered “terrible”, although I am a bit incomplete to mess with d3 internally), but I feel that you are looking for selection.call().
, , selection.call, , :
, . . (docs)
, . :
selection.call(func, arg, arg, ...)
function func(selection, arg, arg, ...) {}
selection.call , . (v4/5):
var dataset = d3.range(10);
d3.select("body").selectAll("div")
.call(log,"body")
.data(dataset)
.call(log,"dataset")
.enter()
.call(log,"enter")
.append("div")
.call(log,"div")
.attr("class", "bar")
.call(log,"bar");
function log(sel,msg) {
console.log(msg,sel);
}
:

.