TheOrcDev / js-set-map-lookups
Install for your project team
Run this command in your project directory to install the skill for your entire team:
mkdir -p .claude/skills/js-set-map-lookups && curl -L -o skill.zip "https://fastmcp.me/Skills/Download/3350" && unzip -o skill.zip -d .claude/skills/js-set-map-lookups && rm skill.zip
Project Skills
This skill will be saved in .claude/skills/js-set-map-lookups/ and checked into git. All team members will have access to it automatically.
Important: Please verify the skill by reviewing its instructions before using it.
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.
0 views
0 installs
Skill Content
--- 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)) ```