mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-22 00:16:15 -04:00
hooks: Don't export syncMapFirst
or mapFirst
Nobody uses these functions outside of this file.
This commit is contained in:
parent
6b42dabf6c
commit
7dba847f21
1 changed files with 4 additions and 4 deletions
|
@ -39,7 +39,7 @@ const hookCallWrapper = (hook, hookName, args, cb) => {
|
||||||
return () => normalize(hook.hook_fn(hookName, args, (x) => cb(normalize(x))));
|
return () => normalize(hook.hook_fn(hookName, args, (x) => cb(normalize(x))));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.syncMapFirst = (lst, fn) => {
|
const syncMapFirst = (lst, fn) => {
|
||||||
let i;
|
let i;
|
||||||
let result;
|
let result;
|
||||||
for (i = 0; i < lst.length; i++) {
|
for (i = 0; i < lst.length; i++) {
|
||||||
|
@ -49,7 +49,7 @@ exports.syncMapFirst = (lst, fn) => {
|
||||||
return [];
|
return [];
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.mapFirst = (lst, fn, cb, predicate) => {
|
const mapFirst = (lst, fn, cb, predicate) => {
|
||||||
if (predicate == null) predicate = (x) => (x != null && x.length > 0);
|
if (predicate == null) predicate = (x) => (x != null && x.length > 0);
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ exports.aCallAll = async (hookName, context, cb) => {
|
||||||
exports.callFirst = (hookName, args) => {
|
exports.callFirst = (hookName, args) => {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (pluginDefs.hooks[hookName] === undefined) return [];
|
if (pluginDefs.hooks[hookName] === undefined) return [];
|
||||||
return exports.syncMapFirst(pluginDefs.hooks[hookName],
|
return syncMapFirst(pluginDefs.hooks[hookName],
|
||||||
(hook) => hookCallWrapper(hook, hookName, args));
|
(hook) => hookCallWrapper(hook, hookName, args));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ const aCallFirst = (hookName, args, cb, predicate) => {
|
||||||
if (!args) args = {};
|
if (!args) args = {};
|
||||||
if (!cb) cb = () => {};
|
if (!cb) cb = () => {};
|
||||||
if (pluginDefs.hooks[hookName] === undefined) return cb(null, []);
|
if (pluginDefs.hooks[hookName] === undefined) return cb(null, []);
|
||||||
exports.mapFirst(
|
mapFirst(
|
||||||
pluginDefs.hooks[hookName],
|
pluginDefs.hooks[hookName],
|
||||||
(hook, cb) => {
|
(hook, cb) => {
|
||||||
hookCallWrapper(hook, hookName, args, (res) => { cb(null, res); });
|
hookCallWrapper(hook, hookName, args, (res) => { cb(null, res); });
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue