| export function initUse(DC) { | export function initUse(DC) { | ||||
| DC.use = function(plugin) { | DC.use = function(plugin) { | ||||
| const installedPlugins = | const installedPlugins = | ||||
| this._installedPlugins || (this._installedPlugins = []) | |||||
| if (installedPlugins.indexOf(plugin) > -1) { | |||||
| this._installedPlugins || (this._installedPlugins = {}) | |||||
| if (this._installedPlugins[plugin.name]) { | |||||
| return this | return this | ||||
| } | } | ||||
| // additional parameters | // additional parameters | ||||
| } else if (typeof plugin === 'function') { | } else if (typeof plugin === 'function') { | ||||
| plugin.apply(null, args) | plugin.apply(null, args) | ||||
| } | } | ||||
| installedPlugins.push(plugin) | |||||
| installedPlugins[plugin.name] = plugin | |||||
| return this | return this | ||||
| } | } | ||||
| } | } |