Create an Object prototype chain based on hierarchy.
Experimental. Create an Object prototype chain based on hierarchy.
$ component install timoxley/proto-merge
var merge = require'proto-merge'var project = mergename: "Main Project"version: 0.01sub_project:name: "Sub Project"forks:version: 0.02// property access works as expected:console.logprojectversion // => '0.0.1'// but note sub_project inherits properties from from its 'parent'console.logprojectsub_projectversion // => '0.0.1'// and can override with its own propertiesconsole.logprojectsub_projectname // => 'Sub Project'// the link is dynamic, so if you change the parent// you also change the childprojectversion = '0.0.2'console.logprojectsub_projectversion // => '0.0.2'// prototypes are also inherited in array membersconsole.logprojectforks0version // => '0.0.3'// you can also use this in silly ways:projectsub_projectsub_projectsub_projectname // => 'Sub Project'
I don't know yet.