Using node, but finding a way to inherit diamonds in JavaScript:
var util = require('util'); function Base(example_value) { console.log(example_value); this.example_property = example_value; this.example_method = function() { ... }; } function Foo(settings) { var f = settings.f; Base.call(x); this.settings = settings; } util.inherits(Foo, Base); function Bar(settings) { var b = settings.b; Base.call(b); this.settings = settings; } util.inherits(Bar, Base); var foo = new Foo({f: 'bar'});
There is no problem ... but then I need to do everything that is available in Foo and Bar (and Base), in another all-encompassing object:
function Top(settings) { Foo.call(this, settings); Bar.call(this, settings); } util.inherits(Top, Foo); util.inhertis(Top, Bar); var top = new Top({some: 'value'});
'value' is printed twice, which is not what I was after. Performing such an inheritance is probably not the best way to find alternatives / suggestions for working with this diamond shape structure.
PS They didn’t include the source code, but changed, I hope, to simplify it - I did it manually, I don’t think there are errors, but the point that I am trying to find should be there.
gratz source share