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.)
pull/4252/head
Richard Hansen 2020-09-05 15:11:06 -04:00 committed by John McLear
parent 9f288480e8
commit 6f3e7d14f6
1 changed files with 2 additions and 2 deletions

View File

@ -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);