Intro
General method provided by deep to fetch and apply inheritance between objects.
Realy useful in many cases, and often so smart.
## Externals files example ```javascript var obj2 = { _backgrounds:["js::path/to/my/object/to/inherit", "instance::path/to/class/to/instanciate/then/apply"], //... } deep.nodes(obj2) .flatten() //... ``` Remarque : Any protocol that provide js objects should work. (as json:: if you load a related store - see [protocols](./stores/native-protocols-and-stores.md)) ## Internal inheritance example ```javascript var obj2 = { a:{ hello:"world" }, b:{ _backgrounds:["this::../a"] } //... } deep.nodes(obj2) .flatten() //... ``` You could obviously mix objects, externals and internals references.deep.nodes(1).log();
Simple
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
var obj = {
test:function(arg){
return arg+" - from obj";
}
}
var obj2 = {
_backgrounds:[obj],
test:deep.compose.after(function(arg){
return arg+" - from obj2";
})
}
deep.nodes(obj2)
.flatten()
.done(function(flattened){
return flattened.test("hello");
})
.log();
Protocol usage
var obj1 = { a:12, b:true, c:{ d:"hello" } };
var obj2 = { b:false }
deep.aup(obj2, obj1);
deep.nodes(obj1).log();
Inner inheritance
ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
var obj1 = { a:12, b:true, c:{ d:"hello" } };
var obj2 = { b:false }
deep.aup(obj2, obj1);
deep.nodes(obj1).log();