Agent Skills: 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.

UncategorizedID: theorcdev/8bitcn-ui/js-set-map-lookups

Install this agent skill to your local

pnpm dlx add-skill https://github.com/TheOrcDev/8bitcn-ui/tree/HEAD/.claude/skills/js-set-map-lookups

Skill Files

Browse the full folder contents for js-set-map-lookups.

Download Skill

Loading file tree…

.claude/skills/js-set-map-lookups/SKILL.md

Skill Metadata

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):

const allowedIds = ['a', 'b', 'c', ...]
items.filter(item => allowedIds.includes(item.id))

Correct (O(1) per check):

const allowedIds = new Set(['a', 'b', 'c', ...])
items.filter(item => allowedIds.has(item.id))