mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
hooks: Inline aCallFirst()
into exports.aCallFirst()
This commit is contained in:
parent
77f480d954
commit
fd5d3ce777
1 changed files with 4 additions and 7 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue