UNPKG

@opengis/fastify-table

Version:

core-plugins

19 lines (18 loc) 534 B
import hookList from './hookList.js'; export default async function applyHook(name, data) { if (!hookList[name]?.length) return null; const result = {}; await Promise.all(hookList[name].map(async (hook) => { const hookData = await hook({ ...data }); if (hookData) { Object.assign(result, hookData); } })).catch((err) => { console.error("applyHook", name, err.toString()); }); if (Object.keys(result).length) { return result; } return null; }