mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 07:56:16 -04:00
staleCode: Async update
This commit is contained in:
parent
0669280af0
commit
009e1d01f7
3 changed files with 47 additions and 37 deletions
|
@ -1,4 +1,3 @@
|
|||
var async = require("async");
|
||||
var _ = require("underscore");
|
||||
|
||||
exports.bubbleExceptions = true
|
||||
|
@ -78,19 +77,22 @@ exports.callAll = function (hook_name, args) {
|
|||
}
|
||||
}
|
||||
|
||||
function aCallAll(hook_name, args, cb) {
|
||||
async function aCallAll(hook_name, args, cb) {
|
||||
if (!args) args = {};
|
||||
if (!cb) cb = function () {};
|
||||
if (exports.plugins.hooks[hook_name] === undefined) return cb(null, []);
|
||||
async.map(
|
||||
exports.plugins.hooks[hook_name],
|
||||
function (hook, cb) {
|
||||
hookCallWrapper(hook, hook_name, args, function (res) { cb(null, res); });
|
||||
},
|
||||
function (err, res) {
|
||||
cb(null, _.flatten(res, true));
|
||||
}
|
||||
);
|
||||
|
||||
var newArray = [];
|
||||
// This should be a map.
|
||||
await exports.plugins.hooks[hook_name].forEach(async function(hook, index){
|
||||
let test = await hookCallWrapper(hook, hook_name, args, function (res) {
|
||||
return Promise.resolve(res);
|
||||
});
|
||||
newArray.push(test)
|
||||
});
|
||||
|
||||
// after forEach
|
||||
cb(null, _.flatten(newArray, true));
|
||||
}
|
||||
|
||||
/* return a Promise if cb is not supplied */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue