
> Contribute functionality to other NPM modules without explicit dependencies. You know, kind of like Eclipse extension points...

## Usage

Imagine some package (let's call it "pluggable") has a need to delegate out functionality to some other, unknown piece of code. To do that, pluggable decides to document that it will read all extensions to it's "pluggable.delegates" extension point.

Now imagine some other module (we'll call it "plugin") would like to be a delegate to pluggable.  In plugin's package.json file, it simply declares it's itention like so:

```json
"extensions": [
  		{
  			"point": "pluggable.delegates",
            "title": "My Awesome Delegate",
  			"exports": "./extensions/awesomeDelegate.js"
  		}
  ]
```
awesomeDelegate.js exports some object (presumably a function that pluggable knows how to call) 

Now all we need is for pluggable to find this extension and use it. That's where pluggington comes in...

In the part of pluggable's code that needs to delegate out, it uses pluggington to find all extensions to "pluggable.delegates":


```js
  var findExtensions = require('pluggington');
  var delegates = findExtensions(__dirname, 'pluggable.delegates');
  
  delegates.forEach(function(delegate){
  	// invoke the function exported by each delegate
    console.log('About to invoke delegate named: ' + delegate.title);
    var delegateFunction = delegate.export;
  	delegateFunction();
  });
```

findExtensions() takes a path and an extensions point name, and will return an array of extension objects returned by all extensions to that extension point name found within that path.  The extension object contains all the key/value pairs declared in package.json, with the exception of "point" and "exports".  The exported object is attached as the "export" property. The path is the parent folder of all extenders.  Plugington will look in each child folder for a package.json file to find the relevant declared extensions.

## Examples

See the projects under the "examples" folder for a simple demo showing how to contribute and read extensions.

## License

IBM Proprietary

