js-data-structures

js-data-structures is a skill for Claude Code, Codex from metarhia/metaskills. It costs 77 tokens per session (2,224 once invoked), scanned A, original, MIT.

Guidance for choosing JavaScript’s built-in collections, such as arrays, sets, maps, and typed arrays. It explains which collection fits different data shapes, operations, and performance needs.

In plain words
What is it for?
Use it when deciding how to store lists, key-value data, unique values, object-linked data, or binary and numeric data in JavaScript.
Why use it?
It helps avoid awkward or inefficient data handling, such as using arrays for unique-value lookups or objects for keys that are not strings.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/metarhia/metaskills/js-data-structures
Any agent
npx skills add metarhia/metaskills --skill js-data-structures
Clone the repo
git clone --depth 1 https://github.com/metarhia/metaskills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for js-data-structures

README.md
[![agentmods](https://agentmods.dev/badge/skills/metarhia/metaskills/js-data-structures.svg)](https://agentmods.dev/skills/metarhia/metaskills/js-data-structures)
Your own site
<a href="https://agentmods.dev/skills/metarhia/metaskills/js-data-structures"><img src="https://agentmods.dev/badge/skills/metarhia/metaskills/js-data-structures.svg" alt="Measured on agentmods" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,224 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00077 $0.02224
Opus 5 $0.00039 $0.01112
Sonnet 5 $0.00015 $0.00445
Haiku 4.5 $0.00008 $0.00222

Measured 5d ago against content hash aec3cd8159d1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

js-data-structures scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/js-data-structures/SKILL.md · 210 lines

How it starts

The opening of the file, as written. The whole thing — 210 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

  • Object field access: O(1) for fixed shapes; dynamic/delete-heavy objects degrade toward dictionary mode
  • Array index get/set, push/pop: O(1); includes/indexOf/splice/shift/unshift: O(n)
  • Map get/set/has/delete, Set add/has/delete: amortized O(1); iteration: O(n)
  • WeakMap/WeakSet get/set/has/delete: amortized O(1); no iteration
  • TypedArray index get/set: O(1); grow/copy: O(n)
  • Prefer the structure whose hot operation is O(1); measure before optimizing rare paths

Readability and semantics:

  • Let the type state the intent: Set = unique membership; Map = keyed registry; Array = ordered sequence; plain Object = record/DTO
  • Prefer a named collection over encoding the same idea in ad-hoc flags, parallel arrays, or stringly keys
  • Use array methods (.map, .filter, .reduce) when they match the transform; use explicit loops when control flow or performance matters
  • Avoid over-abstracting: a small static Array allowlist is clearer than a Set used once

Read the full file on GitHub · 210 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 210 lines · 77 tokens per session scan A aec3cd8159d1

Subscribe to this mod's changes

js-data-structures is a skill published in the GitHub repository metarhia/metaskills (48 stars, last pushed 1mo ago), licensed MIT. It adds 77 tokens to every session and 2,224 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

help

OrchestKit help directory with categorized skill listings. Use when discovering skills for a task, finding the right workflow, or browsing capabilities.

yonatangross/orchestkit · 30 tokens

sbce

Spec-driven BCE workflow where one capability spec equals one business component (same name) and the spec is the boundary contract. Invoked as /sbce new|apply (or by intent), it drives declare → converge; the stack's own test loop is the oracle for "done". new accepts a BC name or a natural-language feature…

AdamBien/airails · 215 tokens

web-components

Architecture and coding rules for single-page applications using web components, BCE layering, lit-html templating, unidirectional Redux-style state management (reduction.js, standards-based), and standards-based client-side routing (Navigation API + URLPattern). Web standards and web platform first, minimal external…

AdamBien/airails · 160 tokens

javascript-conventions

Generic, composable JavaScript (ECMAScript) code conventions — modules, declarations, functions, collections, asynchrony, errors, JSDoc types, naming, and the Baseline lookup that decides which language and standard-library features may be used. Technology-neutral within the JavaScript world; meant to be composed with…

AdamBien/airails · 200 tokens

enterprisifier

Deliberately overengineer code by adding as many patterns, indirections, modules, anti-corruption layers, abstractions, and encapsulations as possible. Zero dependency on implementation. Use when asked to overengineer, enterprisify, enterprise-ify, abstract, add layers, add patterns, or make code "production-ready" in…

AdamBien/airails · 131 tokens

web-static

Build modern static websites using semantic HTML and CSS without external dependencies or build systems. Also owns the verification loop for such sites — drives the rendered pages through Chrome DevTools MCP (console, accessibility snapshot, viewport resize, dark/reduced-motion emulation, Lighthouse), executes the…

AdamBien/airails · 183 tokens