MCP HubMCP Hub
スキル一覧に戻る

data-structures

majiayu000
更新日 Yesterday
19 閲覧
58
9
58
GitHubで表示
その他data

について

このスキルは、本番環境で使用可能なコード例を伴った包括的なJavaScriptオブジェクトと配列のリファレンス資料を提供します。実用的な実装に向けて、操作メソッド、プロトタイプ継承、複雑なデータ構造パターンを網羅しています。開発者は、組み込みのパラメータ検証とリトライロジーを備えた信頼性の高い、すぐに使用できるJavaScriptデータ構造ソリューションが必要な際にこれを活用すべきです。

クイックインストール

Claude Code

推奨
プラグインコマンド推奨
/plugin add https://github.com/majiayu000/claude-skill-registry
Git クローン代替
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/data-structures

このコマンドをClaude Codeにコピー&ペーストしてスキルをインストールします

ドキュメント

Data Structures Skill

Quick Reference Card

Object Operations

// Create
const obj = { name: 'Alice', age: 30 };

// Access
obj.name;           // Dot notation
obj['name'];        // Bracket notation
obj?.address?.city; // Optional chaining

// Modify
obj.email = '[email protected]';       // Add/update
delete obj.age;              // Remove
const { name, ...rest } = obj; // Destructure

Object Methods

Object.keys(obj);       // ['name', 'age']
Object.values(obj);     // ['Alice', 30]
Object.entries(obj);    // [['name','Alice'], ['age',30]]
Object.fromEntries(entries);  // Reverse

Object.assign({}, a, b);  // Shallow merge
{ ...a, ...b };           // Spread merge (preferred)

Object.freeze(obj);       // Immutable
Object.seal(obj);         // No add/delete

Array Methods Cheat Sheet

Transform (new array)

arr.map(x => x * 2);         // Transform each
arr.filter(x => x > 0);      // Keep matches
arr.slice(1, 3);             // Extract portion
arr.flat(2);                 // Flatten nested
arr.flatMap(x => [x, x*2]);  // Map + flatten

Search

arr.find(x => x > 5);        // First match
arr.findIndex(x => x > 5);   // First index
arr.findLast(x => x > 5);    // Last match (ES2023)
arr.includes(5);             // Boolean check
arr.indexOf(5);              // Index or -1

Reduce

arr.reduce((acc, x) => acc + x, 0);  // Sum
arr.reduce((acc, x) => ({ ...acc, [x.id]: x }), {});  // Index by

Check

arr.every(x => x > 0);       // All pass
arr.some(x => x > 0);        // Any pass

Mutate (modify original)

arr.push(x);     // Add end
arr.pop();       // Remove end
arr.unshift(x);  // Add start
arr.shift();     // Remove start
arr.splice(i, n, ...items);  // Remove/insert
arr.sort((a,b) => a - b);    // Sort
arr.reverse();   // Reverse

Destructuring

// Object
const { name, age = 0 } = user;
const { name: userName } = user;  // Rename
const { address: { city } } = user;  // Nested

// Array
const [first, , third] = arr;  // Skip
const [head, ...tail] = arr;   // Rest
[a, b] = [b, a];               // Swap

Data Transformation Patterns

// Group by
const byRole = users.reduce((acc, u) => {
  (acc[u.role] ??= []).push(u);
  return acc;
}, {});

// Unique values
const unique = [...new Set(arr)];

// Index by ID
const byId = arr.reduce((acc, x) => ({ ...acc, [x.id]: x }), {});

Troubleshooting

Common Issues

ProblemSymptomFix
Shallow copy bugNested changes sharedUse structuredClone()
Mutation side effectOriginal changedUse spread/map
undefined accessProperty doesn't existUse ?. optional chain
Sort not workingWrong orderProvide compare function

Deep Clone

// Modern (preferred)
const deep = structuredClone(original);

// JSON (limited - no functions, dates)
const deep = JSON.parse(JSON.stringify(original));

Debug Checklist

// 1. Inspect structure
console.log(JSON.stringify(obj, null, 2));

// 2. Check array vs object
console.log(Array.isArray(value));

// 3. Check prototype
console.log(Object.getPrototypeOf(obj));

Production Patterns

Immutable Update

// Object
const updated = { ...user, name: 'New Name' };

// Array
const added = [...arr, newItem];
const removed = arr.filter(x => x.id !== id);
const updated = arr.map(x => x.id === id ? { ...x, ...changes } : x);

Safe Access

const city = user?.address?.city ?? 'Unknown';
const first = arr?.[0] ?? defaultValue;

Related

  • Agent 03: Objects & Arrays (detailed learning)
  • Skill: fundamentals: Variables and types
  • Skill: modern-javascript: ES6+ features

GitHub リポジトリ

majiayu000/claude-skill-registry
パス: skills/data-structures

関連スキル

content-collections

メタ

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

スキルを見る

polymarket

メタ

This skill enables developers to build applications with the Polymarket prediction markets platform, including API integration for trading and market data. It also provides real-time data streaming via WebSocket to monitor live trades and market activity. Use it for implementing trading strategies or creating tools that process live market updates.

スキルを見る

hybrid-cloud-networking

メタ

This skill configures secure hybrid cloud networking between on-premises infrastructure and cloud platforms like AWS, Azure, and GCP. Use it when connecting data centers to the cloud, building hybrid architectures, or implementing secure cross-premises connectivity. It supports key capabilities such as VPNs and dedicated connections like AWS Direct Connect for high-performance, reliable setups.

スキルを見る

llamaindex

メタ

LlamaIndex is a data framework for building RAG-powered LLM applications, specializing in document ingestion, indexing, and querying. It provides key features like vector indices, query engines, and agents, and supports over 300 data connectors. Use it for document Q&A, chatbots, and knowledge retrieval when building data-centric applications.

スキルを見る