js-data-structures

Installation
SKILL.md

Native Data Structures (JavaScript)

Choosing a native collection

  • Fixed schema / DTO / JSON: use Object (avoid Map, no JSON.stringify)
  • Dynamic string-to-value dict: use Map or Object.create(null) (avoid plain {} if keys are user input)
  • Non-string keys, insertion order, .size: use Map (avoid Object)
  • Ordered list, index access, transform: use Array (avoid Set, no indexes)
  • Unique values, fast membership: use Set (avoid Array.includes on large/dynamic sets)
  • Attach data to objects without retaining them: use WeakMap (avoid Map, leaks)
  • Track object presence without retaining: use WeakSet (avoid Set, leaks)
  • Numeric / binary data, I/O, crypto: use TypedArray / ArrayBuffer (avoid number[] for hot binary work)
  • Hot queue / deque / stack ends: do not rely on Array.shift/unshift — use a custom ring or linked structure

Complexity and code characteristics

Choose a structure for the property you need to control — not only for speed.

Big-O (typical average case; n = collection size):

Installs
14
GitHub Stars
59
First Seen
Mar 16, 2026