UNPKG

n8n-nodes-duckduckgo-search

Version:

AI Agent-ready n8n community node for DuckDuckGo search. Search the web, images, news, and videos with no API key required and no outbound telemetry. Optionally fetch and extract the main text of result pages or any URL, and get DuckDuckGo Instant Answers

41 lines (40 loc) 1.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCached = getCached; exports.setCache = setCache; exports.clearCache = clearCache; exports.getCacheSize = getCacheSize; exports.pruneExpiredEntries = pruneExpiredEntries; const cacheStore = new Map(); function getCached(key) { const entry = cacheStore.get(key); if (!entry) { return undefined; } if (Date.now() > entry.expiresAt) { cacheStore.delete(key); return undefined; } return entry.value; } function setCache(key, value, ttl) { const expiresAt = Date.now() + ttl * 1000; cacheStore.set(key, { value, expiresAt }); } function clearCache() { cacheStore.clear(); } function getCacheSize() { return cacheStore.size; } function pruneExpiredEntries() { const now = Date.now(); let removed = 0; for (const [key, entry] of cacheStore.entries()) { if (now > entry.expiresAt) { cacheStore.delete(key); removed++; } } return removed; }