Skip to main content
Glama
asyncwrap.ts1.19 kB
import {ISkillServiceParams} from '../../types/skillType.js'; interface IAsyncwrapOptions { func: Function; getStatsData: ISkillServiceParams['getStatsData']; setStatsData: ISkillServiceParams['setStatsData']; } /** * Used for wrapping function calls with await() in skills, to accurately time computation time. * This does mean that the function being called will not be counted in the computation time, so make sure that the function you're calling isn't also using this wrapper. * * @param {object} options * @param {Function} options.func - The function to wrap with async. * @param {Function} options.getStatsData - The function to get the stats data from evaluateCode. * @param {Function} options.setStatsData - The function to set the stats data from evaluateCode. * * @return {Promise<any>} The result of the function call. */ export const asyncwrap = async (options: IAsyncwrapOptions): Promise<any> => { const {func, getStatsData, setStatsData} = options; const start = Date.now(); const result = await func(); const end = Date.now(); const waitTime = getStatsData('waitTime'); setStatsData('waitTime', waitTime + end - start); return result; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/leo4life2/minecraft-mcp-http'

If you have feedback or need assistance with the MCP directory API, please join our Discord server