JS

js-set-map-lookups

Replaces inefficient O(n) array lookups with O(1) Set or Map operations for better performance.

Install

mkdir -p .claude/skills/js-set-map-lookups && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3350" && unzip -o skill.zip -d .claude/skills/js-set-map-lookups && rm skill.zip

Installs to .claude/skills/js-set-map-lookups

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

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.
167 chars✓ has a “when” trigger
Beginner

Key capabilities

  • Identify array.includes() for repeated checks
  • Suggest converting arrays to Set for O(1) lookups
  • Suggest converting arrays to Map for O(1) lookups

How it works

The skill analyzes code for array.includes() calls used in repeated membership checks and provides an optimized alternative using JavaScript Set or Map objects.

Inputs & outputs

You give it
Code snippet with array.includes() for membership checks
You get back
Refactored code using Set.has() or Map.has() for O(1) lookups

When to use js-set-map-lookups

  • Optimizing large data filter operations
  • Refactoring slow array.includes() calls
  • Improving lookup speed for ID collections

About this skill

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

How it compares

This skill automatically suggests and demonstrates a performance optimization for membership checks, contrasting with manual code review and refactoring.

Compared to similar skills

js-set-map-lookups side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
js-set-map-lookups (this skill)17moNo flagsBeginner
agent-refinement16moReviewAdvanced
typescript-review392moNo flagsIntermediate
react-modernization212moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

Search skills

Search the agent skills registry