web-utilities-native-js
lodashのような外部ライブラリに頼らず、最新のJavaScript標準機能を使って、ウェブ開発でよく使う便利な処理を効率的に実現するSkill。
📜 元の英語説明(参考)
Modern native JavaScript (ES2022-ES2025) utility patterns that replace lodash
🇯🇵 日本人クリエイター向け解説
lodashのような外部ライブラリに頼らず、最新のJavaScript標準機能を使って、ウェブ開発でよく使う便利な処理を効率的に実現するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o web-utilities-native-js.zip https://jpskill.com/download/10325.zip && unzip -o web-utilities-native-js.zip && rm web-utilities-native-js.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10325.zip -OutFile "$d\web-utilities-native-js.zip"; Expand-Archive "$d\web-utilities-native-js.zip" -DestinationPath $d -Force; ri "$d\web-utilities-native-js.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
web-utilities-native-js.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
web-utilities-native-jsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
[Skill 名] web-utilities-native-js
ネイティブ JavaScript ユーティリティパターン
クイックガイド: ユーティリティライブラリよりもネイティブ JavaScript (ES2022-ES2025) を優先してください。ディープクローンには
structuredClone、グループ化にはObject.groupBy、ES2023 のイミュータブルな配列メソッド (toSorted、toReversed、with)、集合演算には ES2025 の Set メソッドを使用してください。ネイティブの代替手段が本当に存在しない場合や、必要な機能 (debounce のキャンセル/flush、配列戦略を用いたディープマージ) が不足している場合にのみ、ユーティリティライブラリを使用してください。
<critical_requirements>
重要: この Skill を使用する前に
すべてのコードは CLAUDE.md のプロジェクト規約に従う必要があります (kebab-case、名前付きエクスポート、インポート順序、
import type、名前付き定数)
(ユーティリティライブラリを検討する前に、必ずネイティブの ES2022+ メソッドを使用してください - まずこの Skill を確認してください)
(必ずイミュータブルな配列メソッド (toSorted、toReversed、toSpliced、with) を、破壊的なメソッドの代わりに使用してください)
(ディープクローンには必ず structuredClone を使用してください - JSON.parse/JSON.stringify ハックは使用しないでください)
(すべての数値に対して名前付き定数を定義してください - ユーティリティ関数にマジックナンバーを使用しないでください)
</critical_requirements>
自動検出: ネイティブ JavaScript ユーティリティ、lodash の代替、ES2023 配列メソッド、toSorted、toReversed、structuredClone、Object.groupBy、Set union、Set intersection、optional chaining、nullish coalescing、at()、findLast
使用する場合:
- 配列操作 (find、filter、sort、reverse、chunk、unique、group)
- オブジェクト操作 (pick、omit、merge、clone、groupBy)
- 集合演算 (union、intersection、difference)
- 外部ライブラリなしでのディープクローン
- 関数ユーティリティ (debounce、throttle、memoize)
使用しない場合:
- カスタム配列処理戦略を用いた複雑なディープマージ - ライブラリを使用してください
- 大規模なデータセットに対する遅延評価チェーン - lodash チェーンはこれに最適化されています
- クローンする必要がある関数を含むオブジェクト -
structuredCloneは関数をクローンできません - キャンセル、flush、leading/trailing を備えたフル機能の debounce/throttle - ライブラリを使用してください
カバーする主要なパターン:
- 安全なプロパティアクセス (optional chaining + nullish coalescing が
_.getを置き換えます) - イミュータブルな配列操作 (
toSorted、toReversed、toSpliced、with) structuredCloneによるディープクローン (Map、Set、Date、循環参照を処理します)Object.groupBy/Map.groupBy(ES2024 - reduce ベースのグループ化を置き換えます)- ES2025 Set メソッド (union、intersection、difference、symmetricDifference)
- オブジェクトの pick/omit、一意な値、チャンク化、平坦化
詳細なリソース:
- examples/core.md - 安全なアクセス、ディープクローン、イミュータブルな配列、findLast
- examples/arrays.md - 一意な値、集合演算、グループ化、チャンク化、ソート
- examples/objects.md - Pick、omit、merge、mapKeys/mapValues、freeze
- reference.md - 意思決定フレームワーク、lodash からネイティブへの対応表、危険信号、アンチパターン
<philosophy>
Philosophy
最新の JavaScript (ES2022-ES2025) は、一般的なユーティリティライブラリ関数の約 80% に対してネイティブの代替手段を提供します。ネイティブメソッドを使用することは、次のことを意味します。
- バンドルコストゼロ - ユーザーに送信される追加のバイトはありません
- パフォーマンスの向上 - ネイティブ実装はエンジン最適化されています
- 将来性 - 標準は進化しますが、ライブラリはそうでない可能性があります
- デバッグの簡素化 - ステップスルーするライブラリの内部構造はありません
重要な原則: 最初にネイティブ JavaScript を確認してください。本当に欠落している機能にのみユーティリティライブラリを使用してください。
// ネイティブは無料です - インポートは不要です
const unique = [...new Set(items)];
const last = items.at(-1);
const sorted = items.toSorted((a, b) => a.name.localeCompare(b.name));
const cloned = structuredClone(complexObject);
const grouped = Object.groupBy(items, (item) => item.category);
ES バージョンリファレンス:
| 機能 | ES バージョン | ブラウザのサポート |
|---|---|---|
Optional chaining (?.) |
ES2020 | すべての最新ブラウザ |
Nullish coalescing (??) |
ES2020 | すべての最新ブラウザ |
at() 負のインデックス |
ES2022 | すべての最新ブラウザ |
toSorted、toReversed、with |
ES2023 | すべての最新ブラウザ |
Object.groupBy、Map.groupBy |
ES2024 | Chrome 117+、Safari 17.4+ |
| Set メソッド (union など) | ES2025 | Chrome 122+、Safari 17+ |
</philosophy>
<patterns>
コアパターン
パターン 1: 安全なプロパティアクセス
Optional chaining + nullish coalescing は、バンドルコストゼロで _.get を置き換えます。
const DEFAULT_CITY = "Unknown";
const city = user?.address?.city ?? DEFAULT_CITY;
const result = service?.logger?.log?.("message"); // メソッド呼び出し
const first = data?.items?.[0]?.name ?? "No items"; // 配列アクセス
これが重要な理由: null/undefined を適切に処理し、TypeScript で型安全であり、ランタイムコストがかかりません。
完全なパターンについては、examples/core.md を参照してください。
パターン 2: イミュータブルな配列操作 (ES2023)
常にイミュータブルなバリアントを使用してください - リアクティブフレームワークと共有状態にとって非常に重要です。
const sorted = items.toSorted((a, b) => a.price - b.price); // .sort() ではありません
const reversed = items.toReversed(); // .reverse() ではありません
const updated = items.with(1, newItem); // items[1] = x ではありません
const removed = items.toSpliced(1, 1); // .splice() ではありません
これが重要な理由: 破壊的なメソッドは、変更を検出するために参照の等価性に依存する共有状態およびリアクティブフレームワークでバグを引き起こします。
イミュータブルな更新パターンについては、examples/core.md を参照してください。
パターン 3: structuredClone によるディープクローン
JSON ラウンドトリップと lodash _.cloneDeep を置き換えます。JSON が処理できない型を処理します。
const cloned = structuredClone(complexObject);
// 保持するもの: Date、Map、Set、RegExp、ArrayBuffer、循環参照
// クローンできないもの: 関数、DOM ノード、カスタムプロパティを持つ Error オブジェクト
これが重要な理由: JSON.parse(JSON.stringify()) は、ひそかに corr
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Native JavaScript Utility Patterns
Quick Guide: Prefer native JavaScript (ES2022-ES2025) over utility libraries. Use
structuredClonefor deep cloning,Object.groupByfor grouping, ES2023 immutable array methods (toSorted,toReversed,with), and ES2025 Set methods for set operations. Only reach for utility libraries when native alternatives genuinely don't exist or lack needed features (cancel/flush on debounce, deep merge with array strategies).
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use native ES2022+ methods before considering utility libraries - check this skill first)
(You MUST use immutable array methods (toSorted, toReversed, toSpliced, with) instead of mutating methods)
(You MUST use structuredClone for deep cloning - NOT JSON.parse/JSON.stringify hacks)
(You MUST define named constants for all numeric values - NO magic numbers in utility functions)
</critical_requirements>
Auto-detection: native JavaScript utilities, lodash alternative, ES2023 array methods, toSorted, toReversed, structuredClone, Object.groupBy, Set union, Set intersection, optional chaining, nullish coalescing, at(), findLast
When to use:
- Array manipulation (find, filter, sort, reverse, chunk, unique, group)
- Object operations (pick, omit, merge, clone, groupBy)
- Set operations (union, intersection, difference)
- Deep cloning without external libraries
- Function utilities (debounce, throttle, memoize)
When NOT to use:
- Complex deep merge with custom array-handling strategies - use a library
- Lazy evaluation chains over large datasets - lodash chains are optimized for this
- Objects containing functions that need cloning -
structuredClonecannot clone functions - Full-featured debounce/throttle with cancel, flush, leading/trailing - use a library
Key patterns covered:
- Safe property access (optional chaining + nullish coalescing replaces
_.get) - Immutable array operations (
toSorted,toReversed,toSpliced,with) - Deep cloning with
structuredClone(handles Map, Set, Date, circular refs) Object.groupBy/Map.groupBy(ES2024 - replaces reduce-based grouping)- ES2025 Set methods (union, intersection, difference, symmetricDifference)
- Object pick/omit, unique values, chunking, flattening
Detailed Resources:
- examples/core.md - Safe access, deep cloning, immutable arrays, findLast
- examples/arrays.md - Unique values, set operations, grouping, chunking, sorting
- examples/objects.md - Pick, omit, merge, mapKeys/mapValues, freeze
- reference.md - Decision frameworks, lodash-to-native table, red flags, anti-patterns
<philosophy>
Philosophy
Modern JavaScript (ES2022-ES2025) provides native alternatives for ~80% of common utility library functions. Using native methods means:
- Zero bundle cost - No additional bytes shipped to users
- Better performance - Native implementations are engine-optimized
- Future-proof - Standards evolve, libraries may not
- Simpler debugging - No library internals to step through
Key principle: Check native JavaScript first. Only use utility libraries for genuinely missing functionality.
// Native is free - no imports needed
const unique = [...new Set(items)];
const last = items.at(-1);
const sorted = items.toSorted((a, b) => a.name.localeCompare(b.name));
const cloned = structuredClone(complexObject);
const grouped = Object.groupBy(items, (item) => item.category);
ES Version Reference:
| Feature | ES Version | Browser Support |
|---|---|---|
Optional chaining (?.) |
ES2020 | All modern browsers |
Nullish coalescing (??) |
ES2020 | All modern browsers |
at() negative indexing |
ES2022 | All modern browsers |
toSorted, toReversed, with |
ES2023 | All modern browsers |
Object.groupBy, Map.groupBy |
ES2024 | Chrome 117+, Safari 17.4+ |
| Set methods (union, etc.) | ES2025 | Chrome 122+, Safari 17+ |
</philosophy>
<patterns>
Core Patterns
Pattern 1: Safe Property Access
Optional chaining + nullish coalescing replaces _.get with zero bundle cost.
const DEFAULT_CITY = "Unknown";
const city = user?.address?.city ?? DEFAULT_CITY;
const result = service?.logger?.log?.("message"); // method call
const first = data?.items?.[0]?.name ?? "No items"; // array access
Why this matters: Handles null/undefined gracefully, type-safe with TypeScript, no runtime cost.
See examples/core.md for full patterns.
Pattern 2: Immutable Array Operations (ES2023)
Always use immutable variants - critical for reactive frameworks and shared state.
const sorted = items.toSorted((a, b) => a.price - b.price); // not .sort()
const reversed = items.toReversed(); // not .reverse()
const updated = items.with(1, newItem); // not items[1] = x
const removed = items.toSpliced(1, 1); // not .splice()
Why this matters: Mutating methods cause bugs in shared state and reactive frameworks that rely on reference equality to detect changes.
See examples/core.md for immutable update patterns.
Pattern 3: Deep Cloning with structuredClone
Replaces JSON round-trip and lodash _.cloneDeep. Handles types JSON cannot.
const cloned = structuredClone(complexObject);
// Preserves: Date, Map, Set, RegExp, ArrayBuffer, circular references
// Cannot clone: functions, DOM nodes, Error objects with custom properties
Why this matters: JSON.parse(JSON.stringify()) silently corrupts Date (becomes string), Map/Set (becomes {}), and loses undefined.
See examples/core.md for cloning patterns.
Pattern 4: Object.groupBy (ES2024)
Replaces verbose reduce-based grouping and lodash _.groupBy.
const byCategory = Object.groupBy(products, (p) => p.category);
const THRESHOLD = 100;
const byRange = Object.groupBy(items, (item) =>
item.price >= THRESHOLD ? "expensive" : "affordable",
);
// Returns null-prototype object - use Object.hasOwn() not hasOwnProperty
Why this matters: Reduce-based grouping is verbose, error-prone (forgetting key init), and has prototype pollution risk with {}.
See examples/arrays.md for grouping patterns.
Pattern 5: ES2025 Set Methods
Native set operations replace manual filter-based implementations.
const union = setA.union(setB);
const common = setA.intersection(setB);
const diff = setA.difference(setB);
const either = setA.symmetricDifference(setB);
const isSub = setA.isSubsetOf(setB);
// Returns Set - spread to array if needed: [...setA.union(setB)]
Why this matters: Filter + includes/indexOf is O(n^2). Native Set methods are O(n).
See examples/arrays.md for set operations and pre-ES2025 fallbacks.
Pattern 6: Finding from End (ES2023)
findLast and findLastIndex replace reverse-then-find anti-pattern.
const lastError = logs.findLast((log) => log.level === "error");
const lastErrorIdx = logs.findLastIndex((log) => log.level === "error");
Why this matters: [...arr].reverse().find() creates unnecessary copy. findLast is single-pass.
See examples/core.md for findLast patterns.
</patterns>
<red_flags>
RED FLAGS
High Priority:
- Using
JSON.parse(JSON.stringify())for deep clone - loses Date, Map, Set, undefined. UsestructuredClone. - Using mutating array methods (
.sort(),.reverse(),.splice()) on shared state - causes bugs in reactive frameworks. Use ES2023 immutable versions. - Using lodash for operations with native equivalents (
_.get,_.last,_.uniq,_.groupBy) - unnecessary bundle weight. - Using
includes()orindexOf()in loops - O(n) per check. Convert to Set first for O(1) lookups.
Medium Priority:
- Magic numbers like
arr.slice(-3)- use named constants:const RECENT_COUNT = 3. - Reversing arrays to find from end - use
findLast()instead of[...arr].reverse().find(). - Reduce-based grouping - use
Object.groupBy()(ES2024). - Using
arr[arr.length - 1]for last element - usearr.at(-1).
Gotchas & Edge Cases:
structuredClonethrows on functions, DOM nodes - use manual clone if these are present.Object.groupByreturns null-prototype object - nohasOwnProperty. UseObject.hasOwn().- Set methods return Sets, not arrays - spread to array if needed:
[...setA.union(setB)]. toSorted()with no comparator converts elements to strings (likesort()).at()returnsundefinedfor empty arrays or out-of-bounds indices.
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
All code must follow project conventions in CLAUDE.md
(You MUST use native ES2022+ methods before considering utility libraries - check this skill first)
(You MUST use immutable array methods (toSorted, toReversed, toSpliced, with) instead of mutating methods)
(You MUST use structuredClone for deep cloning - NOT JSON.parse/JSON.stringify hacks)
(You MUST define named constants for all numeric values - NO magic numbers in utility functions)
Failure to follow these rules will cause unnecessary bundle bloat and mutation bugs.
</critical_reminders>