IoC for Javascript & Node.js


There are many ways to add features in provides a plugins system to make a package works easily as a plugin for and also as a standalone module or library.

The creation of a plugin can be useful to re-use code easily across multiple projects.


 * Initialization for use as a standalone module.
 * @return {Noder} New `Noder` instance
module.exports = function blog() {

  var noder = require('');

  // also you can create a new instance directly:
  // var noder = new noder.Noder();

  return module.exports.__noder(noder.createNoder());

 * Init `blog` plugin.
 * @param  {Noder} noder  `Noder` instance
 * @return {Noder}        Current `Noder` instance
module.exports.__noder = function blogPlugin(noder) {

  // create config object only if not exists
  noder.$di.addOnce('config', {}, true);

  // sub-modules of blogPlugin
  // that add features to the instance of Noder

  // Always return the instance of Noder to allow chaining
  return noder;

See also, another example on Github.