function packageHierarchy(classes) {
  var map = {};

  function find(name, data) {
    var node = map[name], i;

    if (!node) {
      node = map[name] = data || {name: name, children: []};
      if (name.length) { //name.length
        node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
        node.parent.children.push(node);
        node.key = name.substring(i + 1);
      }
    }
    return node;
  }

  classes.forEach(function(d,i) {
    find(d.name, d);
  });
  return map[""];
}
// Lazily construct the package hierarchy from class names.
Lazily construct the package hierarchy from class names.
Lazily construct the package hierarchy from class names .
function packageHierarchy(classes) {
  var map = {};
  function find(name, data) {
    var node = map[name], i;
    if (!node) {
      node = map[name] = data || {name: name, children: []};
      if (name.length) { 
        node.parent = find(name.substring(0, i = name.lastIndexOf(".")));
        node.parent.children.push(node);
        node.key = name.substring(i + 1);
      }
    }
    return node;
  }
  classes.forEach(function(d,i) {
    find(d.name, d);
  });
  return map[""];
}
function packageHierarchy ( classes ) { var map = { } ; function find ( name , data ) { var node = map [ name ] , i ; if ( ! node ) { node = map [ name ] = data || { name : name , children : [ ] } ; if ( name . length ) { node . parent = find ( name . substring ( 0 , i = name . lastIndexOf ( "." ) ) ) ; node . parent . children . push ( node ) ; node . key = name . substring ( i + 1 ) ; } } return node ; } classes . forEach ( function ( d , i ) { find ( d . name , d ) ; } ) ; return map [ "" ] ; }
Lazily construct the package hierarchy from class names.
Lazily construct the package hierarchy from class names .
//name.length