Define complex prototype chains with vanilla nested objects.
$ npm install proto-merge
$ component install timoxley/proto-merge
APIs often need a little prototype magic, yet the overhead of verbose prototype definitions will ruin the elegance / brevity of the code.
proto-merge simplifies complex prototype chaining definitions to
var merge =// all objects inherit from their 'parent' objectsvar project =// property access works as expected:console // => '0.0.1'// sub_project inherits properties from from its 'parent'console // => '0.0.1'// sub_project can override with its own propertiesconsole // => 'Sub Project'// the link is dynamic, so if you change the parent// you also change the childprojectversion = '0.0.2'console // => '0.0.2'// prototypes are also inherited in array membersconsole // => '0.0.2'console // => '0.0.1'
As with all magic, use responsibly.