Skip to main content
Glama
execute-with-thenable.js712 B
'use strict' const { isPromiseLike } = require('./is-promise-like') const { kAvvio } = require('./symbols') /** * @callback ExecuteWithThenableCallback * @param {Error} error * @returns {void} */ /** * @param {Function} func * @param {Array<any>} args * @param {ExecuteWithThenableCallback} [callback] */ function executeWithThenable (func, args, callback) { const result = func.apply(func, args) if (isPromiseLike(result) && !result[kAvvio]) { // process promise but not avvio mock thenable result.then(() => process.nextTick(callback), (error) => process.nextTick(callback, error)) } else if (callback) { process.nextTick(callback) } } module.exports = { executeWithThenable }

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/krtw00/search-mcp'

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