diff --git a/packages/core/src/latus.js b/packages/core/src/latus.js index e33fbce..e65a5a8 100644 --- a/packages/core/src/latus.js +++ b/packages/core/src/latus.js @@ -45,6 +45,18 @@ export default class Plugins { }), {}); } + invokeComposed(hook, arg) { + if (!this.hooks[hook]) { + return arg; + } + const parts = hook.split('/'); + const key = parts.pop(); + const plugins = this.config[parts.join('/')][key]; + const fns = plugins + .map((plugin) => this.hooks[hook].find(({plugin: candidate}) => plugin === candidate).fn); + return fns.reverse().reduce((r, fn) => fn(r, this), arg); + } + invokeFlat(hook, ...args) { if (!this.hooks[hook]) { return [];