JSFiddle - React, Tailwind, and code Playground

JavaScript

function base() {
  var width;

  function my(selection) {
    console.log('base: ' + width);
  }

  my.width = function(value) {
    if (!arguments.length) return width;
    width = value;
    return my;
  };
    
  return my;
}

function bar() {
  var _base = base(); // instantiate _base, which has width() method

  function my(selection) {
    // In here, if you want to get width, you call `_base.width()`
    // and, if there's some shared rendering functionality you want
    // to put in base, you can run it with `selection.call(_base)`
  }

  d3.rebind(my, _base, 'width') // make width() a function of my
  return my;
}

var _bar = bar();
_bar.width(20);
console.log("_bar's width is " + _bar.width())