# JS Set Map Lookups

> JS Set Map Lookups is an Agent Skill for development published in the TheOrcDev/8bitcn-ui repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

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.

- Skill name: `js-set-map-lookups`
- Category: [Development](https://www.openparable.com/skill/development/1)
- Source: https://github.com/TheOrcDev/8bitcn-ui/blob/HEAD/.claude/skills/js-set-map-lookups/SKILL.md
- Repository: TheOrcDev/8bitcn-ui (1,945 GitHub stars when collected)

## SKILL.md

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

---

Source: https://www.openparable.com/skill/development/js-set-map-lookups (OpenParable). Cite the canonical URL above.
