duojs/duo — pull request #381 by dominicbarnes (2014-11-06 23:10:38+00:00)
Title: adding way to check if something has already been included

When writing plugins, I thought it would be convenient for duo to add a little API for checking if something has already been included. This has the benefit of simplifying plugins, since they don't need their own boolean flag to make sure they don't include the same thing more than once.

This could also be useful for plugins that may want to inject something that another plugin may want to inject. For example, I'm using a module that generally works only for node, but only uses `path`, so I figured I would probably drop in the browserify port. With that in mind, I'm sure more than 1 plugin will want to do this.

```js
// before
module.exports = function () {
var included = false;
return function *(file) {
// do stuff
if (!included) file.include("path", "...");
// do more stuff
};
};

// after
module.exports = function () {
return function *(file) {
// do stuff
if (!file.included('path')) file.include("path", "...");
// do more stuff
};
};
```