$ show leonardomso/33-js-concepts
This repository is an educational documentation project, not a runtime application: index.js is a placeholder comment, and the only executable code is a ~70-file Vitest test suite whose purpose is to verify, line-by-line, the code examples embedded in ~60 MDX documentation pages. The docs cover 33 core JavaScript concepts plus a 'Beyond 33' extension of ~29 advanced topics (observer APIs, memory management, WeakMap/WeakSet, IndexedDB, etc.), rendered as a Mintlify site at 33jsconcepts.com. Each test file maps 1:1 to a concept page and references exact source line numbers in the .mdx files, making the tests executable documentation. GitHub Actions CI runs the suite on push/PR against Node LTS.
The LLM identified 7 files worth highlighting for reuse:
Contains promisifyRequest and openDatabase helpers that wrap IndexedDB's event-driven IDBRequest API in Promises, including the upgrade/transaction lifecycle and a simulated migration path. Solves the recurring 'IndexedDB is callback-hell' problem; the helpers are standalone functions at the top of the test file with zero internal imports and are directly extractable into any browser project. Demonstrates non-obvious skill in bridging event-driven browser APIs to async/await.
Generic memoize implementations (Map and WeakMap variants) plus a memoizeLRU with bounded cache eviction, teaching caching as the unit under test. The LRU variant is a drop-in utility for any JavaScript project and demonstrates non-obvious skill in eviction ordering and reference semantics. Fully self-contained and provably correct via the surrounding test suite.
safeStringify handles circular references via a WeakSet of seen objects, and bigIntReplacer/bigIntReviver round-trip BigInt values through JSON - two recurring production data-serialization problems solved in compact, isolated functions. Also exercises replacer/reviver, toJSON, and serialization edge cases. Directly reusable in any project that stringifies cyclic or BigInt-bearing data.
A mini cookie library (parseCookies, buildCookieString, getCookie, hasCookie) covering RFC-style cookie construction, encoding, and path matching. Correctly parsing document.cookie strings with escaped values and attributes is a recurring pain point in web code; these functions are isolated, parameterized, and tested against edge cases, making them portable as a shared utility.
Full debounce/throttle implementations including leading/trailing edge variants and enhanced versions with cancel/flush control. The cancel/flush API surface is the non-obvious part most naive implementations miss. Self-contained functions under test; extracting them into a standalone utility module requires copying only the function bodies.
A fetchJSON middleware wrapper plus fetchWithTimeout (AbortController) and fetchWithRetry (exponential backoff) - the canonical reliability trio for HTTP in the browser. Demonstrates non-obvious skill in AbortController propagation and retry timing, and the tests run against a mocked global fetch, making the utilities environment-independent and easy to extract.
A storage wrapper that transparently JSON-serializes and deserializes values, plus a safeSetItem variant that degrades gracefully on QuotaExceededError - the two production pain points of Web Storage. Includes feature detection. Small, isolated, and directly portable into any client-side codebase.