Recently I have been reading about javascript patterns, and how to use module pattern to avoid globals. When I look at d3.js hierarchy layout source code, I am not sure if the below is intentional.
d3.layout.hierarchy is using the module pattern, but towards the end, I see many methods outside of it, which I guess are only applicable to layout and its derived objects (partition, tree..).
d3_layout_hierarchyRebind
d3_layout_hierarchyChildren
d3_layout_hierarchyValue
..
Is this intentional, or should be captured within the module?
When the library is built via the makefile, these methods are all enclosed within an anonymous function (see start.js and end.js) for the wrapper code. So none of them are global in the final built-out library. This is a design choice to allow the library to be easily split into many files without requiring an anonymous function wrapper for each (as would be the case with require.js-style modules).