Skip to main content
Glama

MCP Environment & Installation Manager

by devlimelabs
func-utils.js2.11 kB
/** * Creates a debounced function that delays invoking func until after wait milliseconds * @param func Function to debounce * @param wait Wait time in milliseconds */ export function debounce(func, wait) { let timeout = null; return function (...args) { const later = () => { timeout = null; func(...args); }; if (timeout !== null) { clearTimeout(timeout); } timeout = setTimeout(later, wait); }; } /** * Creates a throttled function that only invokes func at most once per wait period * @param func Function to throttle * @param wait Wait time in milliseconds */ export function throttle(func, wait) { let timeout = null; let lastArgs = null; let lastCallTime = 0; return function (...args) { const now = Date.now(); const timeSinceLastCall = now - lastCallTime; lastArgs = args; if (timeSinceLastCall >= wait) { lastCallTime = now; func(...args); } else if (timeout === null) { timeout = setTimeout(() => { lastCallTime = Date.now(); timeout = null; if (lastArgs !== null) { func(...lastArgs); } }, wait - timeSinceLastCall); } }; } /** * Creates a function that is only called once * @param func Function to call once */ export function once(func) { let called = false; let result; return function (...args) { if (!called) { called = true; result = func(...args); } return result; }; } /** * Creates a memoized function that caches results * @param func Function to memoize */ export function memoize(func) { const cache = new Map(); return function (...args) { const key = JSON.stringify(args); if (cache.has(key)) { return cache.get(key); } const result = func(...args); cache.set(key, result); return result; }; } //# sourceMappingURL=func-utils.js.map

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/devlimelabs/mcp-env-manager-mcp'

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