From fd5d3ce777c5cb93e3c49cccc77289099afa2b71 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Mon, 1 Feb 2021 00:34:49 -0500 Subject: [PATCH] hooks: Inline `aCallFirst()` into `exports.aCallFirst()` --- src/static/js/pluginfw/hooks.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index c570068cf..75e37315f 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -362,7 +362,10 @@ exports.callFirst = (hookName, context) => { return []; }; -const aCallFirst = async (hookName, context, predicate = null) => { +exports.aCallFirst = async (hookName, context, cb = null, predicate = null) => { + if (cb != null) { + return await attachCallback(exports.aCallFirst(hookName, context, null, predicate), cb); + } if (!context) context = {}; if (predicate == null) predicate = (val) => val.length; const hooks = pluginDefs.hooks[hookName] || []; @@ -373,12 +376,6 @@ const aCallFirst = async (hookName, context, predicate = null) => { return []; }; -/* return a Promise if cb is not supplied */ -exports.aCallFirst = (hookName, context, cb, predicate) => { - if (cb == null) return aCallFirst(hookName, context, predicate); - util.callbackify(aCallFirst)(hookName, context, predicate, cb); -}; - exports.exportedForTestingOnly = { callHookFnAsync, callHookFnSync,