From 6f3e7d14f66b3574232c2fcc3bebb93949c2f1bb Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sat, 5 Sep 2020 15:11:06 -0400 Subject: [PATCH] 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.) --- src/static/js/pluginfw/hooks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/static/js/pluginfw/hooks.js b/src/static/js/pluginfw/hooks.js index b2c2aaab2..aadb2216e 100644 --- a/src/static/js/pluginfw/hooks.js +++ b/src/static/js/pluginfw/hooks.js @@ -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);