js-data-structures
Installation
SKILL.md
Native Data Structures (JavaScript)
Choosing a native collection
- Fixed schema / DTO / JSON: use
Object(avoidMap, noJSON.stringify) - Dynamic string-to-value dict: use
MaporObject.create(null)(avoid plain{}if keys are user input) - Non-string keys, insertion order,
.size: useMap(avoidObject) - Ordered list, index access, transform: use
Array(avoidSet, no indexes) - Unique values, fast membership: use
Set(avoidArray.includeson large/dynamic sets) - Attach data to objects without retaining them: use
WeakMap(avoidMap, leaks) - Track object presence without retaining: use
WeakSet(avoidSet, leaks) - Numeric / binary data, I/O, crypto: use TypedArray /
ArrayBuffer(avoidnumber[]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):