Skip to main content

js-set-map-lookups

Use Set and Map for O(1) membership lookups instead of array.includes(). Apply when checking membership repeatedly or performing frequent lookups against a collection.

Source facts

Repository
TheOrcDev/8bitcn-ui
Last source activity
January 16, 2026 at 09:09
Detected SKILL.md language
English
Stars
2,043
Forks
120

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
js-set-map-lookups
description
Use Set and Map for O(1) membership lookups instead of array.includes(). Apply when checking membership repeatedly or performing frequent lookups against a collection.
## Use Set/Map for O(1) Lookups Convert arrays to Set/Map for repeated membership checks. **Incorrect (O(n) per check):** ```typescript const allowedIds = ['a', 'b', 'c', ...] items.filter(item => allowedIds.includes(item.id)) ``` **Correct (O(1) per check):** ```typescript const allowedIds = new Set(['a', 'b', 'c', ...]) items.filter(item => allowedIds.has(item.id)) ```
View on GitHub