mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
hooks: Always return a list from aCallFirst
and callFirst
Every existing caller of `aCallFirst` expects a list and will throw an exception if given `undefined`. (Nobody calls `callFirst`, except maybe plugins.)
This commit is contained in:
parent
9f288480e8
commit
6f3e7d14f6
1 changed files with 2 additions and 2 deletions
|
@ -34,14 +34,14 @@ exports.syncMapFirst = function (lst, fn) {
|
|||
result = fn(lst[i])
|
||||
if (result.length) return result;
|
||||
}
|
||||
return undefined;
|
||||
return [];
|
||||
}
|
||||
|
||||
exports.mapFirst = function (lst, fn, cb) {
|
||||
var i = 0;
|
||||
|
||||
var next = function () {
|
||||
if (i >= lst.length) return cb(undefined);
|
||||
if (i >= lst.length) return cb(null, []);
|
||||
fn(lst[i++], function (err, result) {
|
||||
if (err) return cb(err);
|
||||
if (result.length) return cb(null, result);
|
||||
|
|
Loading…
Reference in a new issue