$ show zhensherlock/company-autocomplete
This is a browser-side library providing an autocomplete input for company names, packaged as an npm module (company-autocomplete). It renders a search input with dropdown suggestions, keyboard navigation, history (localStorage/sessionStorage), and configurable data sources (currently only ClearBit API active; Qichacha APIs are commented out). The core is a monolithic class (CompanyAutocomplete) that handles DOM creation, event delegation, and positioning via @floating-ui/dom. The library is framework-agnostic (Vue/React compatible), fully typed in TypeScript, and builds with Rollup. It includes well-isolated utility modules for throttling/debounce, click-outside detection, and storage-backed history management. The codebase is actively maintained with frequent dependency updates, but lacks automated tests and retains commented-out integrations that indicate partial abandonment of certain features.
The LLM identified 3 files worth highlighting for reuse:
Generic throttle and debounce functions with configurable leading/trailing/once options. Fully typed and side-effect-free; can be extracted and used in any JavaScript/TypeScript project. Demonstrates clean implementation of time-based function rate limiting.
Simple history CRUD using Web Storage API (localStorage/sessionStorage). Stores up to 5 entries, deduplicates by ID, and provides add/get/remove functions. Easily reusable in any browser-based application needing recent-item tracking.
Lightweight click-outside detection utility. Attaches a document click listener that invokes a callback when the click occurs outside the given element. Self-contained and framework-agnostic; applicable to modals, dropdowns, and popovers in any web project.