<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Javascript on Commentary of Takao</title><link>https://takao.blog/en/tags/javascript/</link><description>Recent content in Javascript on Commentary of Takao</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>Commentary of Takao</copyright><lastBuildDate>Sat, 13 Jun 2026 23:11:50 +0900</lastBuildDate><atom:link href="https://takao.blog/en/tags/javascript/index.xml" rel="self" type="application/rss+xml"/><item><title>Replacing LocalStorage: Dynamic IndexedDB wrapper localForage</title><link>https://takao.blog/en/web/js-indexeddb-localforage-localstorage/</link><pubDate>Fri, 20 Feb 2026 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-indexeddb-localforage-localstorage/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Replacing LocalStorage: Dynamic IndexedDB wrapper localForage" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Client-side storage is a fundamental requirement for modern web applications — offline caches, user preferences, draft data, and session state all need to persist in the browser. For years, &lt;strong&gt;localStorage&lt;/strong&gt; has been the simplest go-to solution, but its limitations become painful as applications grow. This article compares localStorage, raw IndexedDB, and the &lt;strong&gt;localForage&lt;/strong&gt; wrapper library, providing practical guidance for choosing the right storage engine.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-limits-of-localstorage"&gt;The Limits of localStorage
&lt;/h2&gt;&lt;p&gt;localStorage offers a straightforward synchronous key-value API — &lt;code&gt;setItem(key, value)&lt;/code&gt; and &lt;code&gt;getItem(key)&lt;/code&gt; — but it comes with hard constraints:&lt;/p&gt;</description></item><item><title>Unlocking JavaScript RegExp Power with the v Flag</title><link>https://takao.blog/en/web/js-regex-v-flag/</link><pubDate>Wed, 15 Oct 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-regex-v-flag/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Unlocking JavaScript RegExp Power with the v Flag" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Regular expressions in JavaScript have evolved significantly. ES2024 introduces the &lt;strong&gt;&lt;code&gt;v&lt;/code&gt; flag&lt;/strong&gt; — a superset of the &lt;code&gt;u&lt;/code&gt; flag that unlocks powerful set notation, character class subtraction, intersection, and proper Unicode emoji matching. If you&amp;rsquo;ve struggled with complex character class logic or emoji regex patterns, the &lt;code&gt;v&lt;/code&gt; flag is a game-changer.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="what-is-the-v-flag"&gt;What Is the v Flag?
&lt;/h2&gt;&lt;p&gt;The &lt;code&gt;v&lt;/code&gt; flag replaces and extends the &lt;code&gt;u&lt;/code&gt; (unicode) flag. Enable it by appending &lt;code&gt;v&lt;/code&gt; to your regex:&lt;/p&gt;</description></item><item><title>Designing Clean React Custom Hooks for Reusability</title><link>https://takao.blog/en/web/react-custom-hooks-rules/</link><pubDate>Sun, 10 Aug 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/react-custom-hooks-rules/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Designing Clean React Custom Hooks for Reusability" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;As you develop React components, you may find that files grow to hundreds of lines. This happens when &lt;code&gt;useState&lt;/code&gt;, &lt;code&gt;useEffect&lt;/code&gt;, API queries, and validation logic mix with rendering markup, making the component hard to read and maintain.&lt;/p&gt;
&lt;p&gt;This mixing of concerns makes writing unit tests difficult and increases the risk of copy-paste bugs when reusing logic across different views.&lt;/p&gt;
&lt;p&gt;The best way to separate UI (presentation) from business logic (behavior) in React is to create &lt;strong&gt;Custom Hooks&lt;/strong&gt;. This guide outlines the core design guidelines for building reusable custom hooks.&lt;/p&gt;</description></item><item><title>ESM vs CommonJS Interop Challenges in Node.js</title><link>https://takao.blog/en/web/node-esm-cjs-interoperability/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/node-esm-cjs-interoperability/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post ESM vs CommonJS Interop Challenges in Node.js" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Node.js has supported ECMAScript Modules (ESM) since v12, but the ecosystem remains deeply rooted in CommonJS (CJS). Mixing the two module systems in a single project — or consuming CJS packages from ESM code — introduces subtle pitfalls around exports, default imports, and globals. This article maps the interop boundary and provides concrete strategies for a smooth migration.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="cjs-vs-esm-at-a-glance"&gt;CJS vs ESM at a Glance
&lt;/h2&gt;&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Aspect&lt;/th&gt;
					&lt;th&gt;CommonJS&lt;/th&gt;
					&lt;th&gt;ESM&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;File extensions&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.cjs&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;.js&lt;/code&gt;, &lt;code&gt;.mjs&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Default in &lt;code&gt;package.json&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;quot;type&amp;quot;: &amp;quot;commonjs&amp;quot;&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;&amp;quot;type&amp;quot;: &amp;quot;module&amp;quot;&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Loading&lt;/td&gt;
					&lt;td&gt;Synchronous (&lt;code&gt;require()&lt;/code&gt;)&lt;/td&gt;
					&lt;td&gt;Asynchronous (&lt;code&gt;import&lt;/code&gt;)&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Top-level &lt;code&gt;this&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;module.exports&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;&lt;code&gt;undefined&lt;/code&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;__dirname&lt;/code&gt; / &lt;code&gt;__filename&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;Available&lt;/td&gt;
					&lt;td&gt;Not available&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Live bindings&lt;/td&gt;
					&lt;td&gt;Copy exports&lt;/td&gt;
					&lt;td&gt;Live bindings&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;hr&gt;
&lt;h2 id="configuring-the-module-system"&gt;Configuring the Module System
&lt;/h2&gt;&lt;p&gt;You control the module system via the &lt;code&gt;package.json&lt;/code&gt; &lt;code&gt;&amp;quot;type&amp;quot;&lt;/code&gt; field:&lt;/p&gt;</description></item><item><title>Executing Non-Blocking Scripts with requestIdleCallback</title><link>https://takao.blog/en/web/web-performance-requestidlecallback-optimizations/</link><pubDate>Fri, 25 Jul 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/web-performance-requestidlecallback-optimizations/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Executing Non-Blocking Scripts with requestIdleCallback" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;When building complex web applications, maintaining smooth animations and responsive user inputs (ideally matching 60+ FPS frame rates) is essential for a good user experience.&lt;/p&gt;
&lt;p&gt;However, modern applications often require executing low-priority background operations—such as sending analytics data, syncing caches, parsing telemetry logs, or pre-fetching assets.&lt;/p&gt;
&lt;p&gt;Executing these non-urgent tasks as standard async promises or immediate timers can block the main thread mid-frame, causing interface jank or increasing your Interaction to Next Paint (INP) score.&lt;/p&gt;</description></item><item><title>Exciting Features in ECMAScript 2025 (ES16)</title><link>https://takao.blog/en/web/js-es2025-new-features/</link><pubDate>Thu, 15 May 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-es2025-new-features/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Exciting Features in ECMAScript 2025 (ES16)" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Each year, the TC39 committee updates the ECMAScript specifications, introducing new language features and APIs to the JavaScript ecosystem.&lt;/p&gt;
&lt;p&gt;For the upcoming &lt;strong&gt;ECMAScript 2025 (ES16)&lt;/strong&gt; standard, several proposals have reached Stage 3 or Stage 4, indicating they are in the final stages of browser implementation and adoption.&lt;/p&gt;
&lt;p&gt;This article highlights some of the new features coming in ES2025, detailing how they simplify coding patterns.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-promisetry-unifying-synchronous-and-asynchronous-error-handling"&gt;1. Promise.try: Unifying Synchronous and Asynchronous Error Handling
&lt;/h2&gt;&lt;p&gt;A common challenge in JavaScript development is handling both synchronous exceptions and asynchronous Promise rejections in a clean, unified way.&lt;/p&gt;</description></item><item><title>React 19 Official Release and Practical Features Guide</title><link>https://takao.blog/en/web/react-19-new-features-practical/</link><pubDate>Wed, 05 Mar 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/react-19-new-features-practical/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post React 19 Official Release and Practical Features Guide" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;React 19 represents a major paradigm shift for frontend development.&lt;/p&gt;
&lt;p&gt;Features that were previously restricted to meta-frameworks like Next.js—such as &lt;strong&gt;React Server Components (RSC)&lt;/strong&gt; and the &lt;strong&gt;Actions API&lt;/strong&gt; for form handling—are now officially integrated into the stable core React library.&lt;/p&gt;
&lt;p&gt;This guide highlights the most important features in React 19, offering practical code examples and upgrading tips to clean up your codebase.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="1-simplification-of-async-state-with-the-actions-api"&gt;1. Simplification of Async State with the Actions API
&lt;/h2&gt;&lt;p&gt;A standout feature in React 19 is the introduction of &lt;strong&gt;Actions&lt;/strong&gt;, designed to simplify managing asynchronous mutations, loader overlays, and form submissions.&lt;/p&gt;</description></item><item><title>Patterns to Avoid with JavaScript Async/Await</title><link>https://takao.blog/en/web/javascript-async-await-tips/</link><pubDate>Sat, 15 Feb 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/javascript-async-await-tips/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Patterns to Avoid with JavaScript Async/Await" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Since the introduction of &lt;code&gt;async/await&lt;/code&gt; in ES2017, writing asynchronous JavaScript has become far more intuitive. It allows developers to express asynchronous logic in a synchronous-looking structure, drastically improving codebase readability compared to nested Promise chains (&lt;code&gt;.then().catch()&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;However, this clean synchronous-like syntax can hide performance pitfalls and error-handling bugs. In this article, we&amp;rsquo;ll dive into common async/await antipatterns and learn how to refactor them into high-performance, resilient code.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="antipattern-1-unnecessary-serialization-sequential-awaiting"&gt;Antipattern 1: Unnecessary Serialization (Sequential Awaiting)
&lt;/h2&gt;&lt;p&gt;The most common mistake is executing independent asynchronous tasks sequentially, missing opportunities for parallel execution.&lt;/p&gt;</description></item><item><title>File System Access API: Powerful Local File Operations</title><link>https://takao.blog/en/web/file-system-access-api/</link><pubDate>Sat, 28 Dec 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/file-system-access-api/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post File System Access API: Powerful Local File Operations" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;For decades, web applications were limited to reading files through a clunky &lt;code&gt;&amp;lt;input type=&amp;quot;file&amp;quot;&amp;gt;&lt;/code&gt; element and had no reliable way to save changes back to the original file. The File System Access API changes this entirely. It enables web applications to read, write, and manage files and directories directly on the user&amp;rsquo;s local file system — with user permission, of course. This opens the door to building text editors, image editors, IDEs, and productivity tools that feel native.&lt;/p&gt;</description></item><item><title>JavaScript Array Methods: From Basics to Advanced Patterns</title><link>https://takao.blog/en/web/js-array-methods/</link><pubDate>Thu, 12 Dec 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-array-methods/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post JavaScript Array Methods: From Basics to Advanced Patterns" /&gt;&lt;p&gt;JavaScript arrays are the backbone of data manipulation in modern web development. With the ES2023 specification introducing immutable alternatives to long-standing mutating methods, now is the perfect time to revisit how we work with arrays. This article covers the full landscape of array methods, from the familiar &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, and &lt;code&gt;reduce&lt;/code&gt; to cutting-edge additions, with practical examples and performance insights.&lt;/p&gt;
&lt;h2 id="the-array-method-landscape"&gt;The Array Method Landscape
&lt;/h2&gt;&lt;p&gt;Array methods fall into two broad categories: mutating and non-mutating. Methods like &lt;code&gt;push&lt;/code&gt;, &lt;code&gt;pop&lt;/code&gt;, &lt;code&gt;splice&lt;/code&gt;, &lt;code&gt;sort&lt;/code&gt;, and &lt;code&gt;reverse&lt;/code&gt; modify the array in place, while &lt;code&gt;map&lt;/code&gt;, &lt;code&gt;filter&lt;/code&gt;, &lt;code&gt;slice&lt;/code&gt;, and the ES2023 additions create new arrays. The industry trend is shifting toward immutability, which reduces bugs caused by unintended side effects.&lt;/p&gt;</description></item><item><title>JavaScript Typed Arrays: Binary Data Processing in the Browser</title><link>https://takao.blog/en/web/js-typed-arrays/</link><pubDate>Tue, 10 Sep 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-typed-arrays/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post JavaScript Typed Arrays: Binary Data Processing in the Browser" /&gt;&lt;p&gt;JavaScript&amp;rsquo;s native &lt;code&gt;Number&lt;/code&gt; type — an IEEE 754 double-precision float — is inefficient for binary data. Early solutions involved manual byte packing in plain arrays, which was slow and error-prone. ECMAScript 2015 formalized Typed Arrays, bringing C-like memory management to JavaScript. This three-layer architecture — &lt;code&gt;ArrayBuffer&lt;/code&gt;, TypedArray views, and &lt;code&gt;DataView&lt;/code&gt; — enables high-performance binary data processing in the browser and Node.js.&lt;/p&gt;
&lt;h2 id="arraybuffer-foundation"&gt;ArrayBuffer Foundation
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;ArrayBuffer&lt;/code&gt; represents a fixed-length raw binary buffer. It cannot be read or written directly — you must use a view:&lt;/p&gt;</description></item><item><title>JavaScript Module Federation: Micro-Frontends in Practice</title><link>https://takao.blog/en/web/module-federation/</link><pubDate>Tue, 09 Jul 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/module-federation/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post JavaScript Module Federation: Micro-Frontends in Practice" /&gt;&lt;h2 id="introduction"&gt;Introduction
&lt;/h2&gt;&lt;p&gt;Module Federation, introduced in Webpack 5, provides a runtime integration mechanism for building micro-frontend architectures. Unlike build-time integration approaches, it enables independently deployed applications to share code at runtime, facilitating team autonomy and incremental migration without coordinated releases.&lt;/p&gt;
&lt;p&gt;At its core, Module Federation allows a JavaScript application to dynamically load code from another application at runtime. Each participating application exposes a &lt;code&gt;remoteEntry.js&lt;/code&gt; file that serves as the entry point. When a host application needs a component from a remote, it fetches the &lt;code&gt;remoteEntry.js&lt;/code&gt; at runtime and resolves the required module on demand.&lt;/p&gt;</description></item><item><title>JavaScript Proxy and Reflect API: Metaprogramming Patterns</title><link>https://takao.blog/en/web/js-proxy-reflect/</link><pubDate>Tue, 04 Jun 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-proxy-reflect/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post JavaScript Proxy and Reflect API: Metaprogramming Patterns" /&gt;&lt;p&gt;JavaScript&amp;rsquo;s &lt;code&gt;Proxy&lt;/code&gt; and &lt;code&gt;Reflect&lt;/code&gt; APIs are among the most powerful metaprogramming tools available in the language. They allow developers to intercept and customize fundamental operations on objects — property access, assignment, enumeration, function invocation, and even constructor calls. This article explores all 13 proxy traps, the complementary &lt;code&gt;Reflect&lt;/code&gt; API, and real-world patterns used in production frameworks like Vue 3, MobX, and Immer.&lt;/p&gt;
&lt;h2 id="understanding-the-proxy-pattern"&gt;Understanding the Proxy Pattern
&lt;/h2&gt;&lt;p&gt;A &lt;code&gt;Proxy&lt;/code&gt; wraps a target object and intercepts operations via handler functions called traps:&lt;/p&gt;</description></item><item><title>WebSocket for Real-Time Applications: Complete Guide</title><link>https://takao.blog/en/web/websocket-applications/</link><pubDate>Tue, 14 May 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/websocket-applications/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post WebSocket for Real-Time Applications: Complete Guide" /&gt;&lt;p&gt;Real-time functionality has become a baseline expectation for modern web applications. WebSocket provides full-duplex communication channels over a single TCP connection, enabling low-latency data exchange between client and server. This guide covers the WebSocket protocol, implementation patterns, scaling strategies, and practical considerations for building production-grade real-time applications.&lt;/p&gt;
&lt;h2 id="websocket-protocol-overview"&gt;WebSocket Protocol Overview
&lt;/h2&gt;&lt;p&gt;WebSocket begins with an HTTP upgrade handshake. The client sends an HTTP request with an &lt;code&gt;Upgrade: websocket&lt;/code&gt; header, and the server responds with &lt;code&gt;101 Switching Protocols&lt;/code&gt; to establish the connection. Once established, the connection transitions from HTTP to the WebSocket protocol on the same underlying TCP socket.&lt;/p&gt;</description></item><item><title>Node.js Worker Threads: Parallel Processing in Practice</title><link>https://takao.blog/en/web/nodejs-worker-threads/</link><pubDate>Tue, 23 Apr 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/nodejs-worker-threads/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Node.js Worker Threads: Parallel Processing in Practice" /&gt;&lt;p&gt;Node.js has traditionally been single-threaded, relying on asynchronous I/O for concurrency. While this model excels at I/O-bound workloads, CPU-intensive operations block the event loop and degrade application responsiveness. Worker Threads, stabilized in Node.js 12, provide true parallel execution within a single process by running JavaScript in separate V8 isolates. This article covers practical patterns for using worker threads in production.&lt;/p&gt;
&lt;h2 id="worker-lifecycle-and-communication"&gt;Worker Lifecycle and Communication
&lt;/h2&gt;&lt;p&gt;Creating a worker requires a separate JavaScript file that executes in its own V8 isolate with its own heap and event loop.&lt;/p&gt;</description></item><item><title>ES2024 New Features: What's Coming in JavaScript</title><link>https://takao.blog/en/web/es2024-new-features/</link><pubDate>Tue, 12 Mar 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/es2024-new-features/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post ES2024 New Features: What's Coming in JavaScript" /&gt;&lt;p&gt;ECMAScript 2024 (ES15) introduces several long-anticipated features to JavaScript. This article covers the new capabilities with practical examples and guidance on adoption timelines.&lt;/p&gt;
&lt;h2 id="array-grouping-objectgroupby-and-mapgroupby"&gt;Array Grouping: Object.groupBy and Map.groupBy
&lt;/h2&gt;&lt;p&gt;One of the most requested JavaScript features has finally arrived. &lt;code&gt;Object.groupBy&lt;/code&gt; and &lt;code&gt;Map.groupBy&lt;/code&gt; partition array elements into groups based on a callback:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;inventory&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; { &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;asparagus&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;type&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;vegetables&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;quantity&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; { &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;bananas&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;type&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;fruit&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;quantity&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; { &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;goat&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;type&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;meat&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;quantity&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;23&lt;/span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;];
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;byType&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Object.&lt;span style="color:#a6e22e"&gt;groupBy&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;inventory&lt;/span&gt;, ({ &lt;span style="color:#a6e22e"&gt;type&lt;/span&gt; }) =&amp;gt; &lt;span style="color:#a6e22e"&gt;type&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// { vegetables: [{ name: &amp;#34;asparagus&amp;#34;, ... }],
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// fruit: [{ name: &amp;#34;bananas&amp;#34;, ... }],
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;// meat: [{ name: &amp;#34;goat&amp;#34;, ... }] }
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;Map.groupBy&lt;/code&gt; preserves non-string keys, making it ideal for grouping by objects or symbols. This eliminates the need for external libraries or manual &lt;code&gt;reduce&lt;/code&gt; patterns.&lt;/p&gt;</description></item><item><title>ESLint Flat Config: Migration Guide from Legacy .eslintrc</title><link>https://takao.blog/en/web/eslint-flat-config/</link><pubDate>Mon, 26 Feb 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/eslint-flat-config/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post ESLint Flat Config: Migration Guide from Legacy .eslintrc" /&gt;&lt;p&gt;ESLint v9.0, released in 2024, made the flat config system (&lt;code&gt;eslint.config.js&lt;/code&gt;) the default, replacing the legacy &lt;code&gt;.eslintrc&lt;/code&gt; format that had been in use for over a decade. This migration guide covers the complete transition process, new concepts, and practical examples.&lt;/p&gt;
&lt;h2 id="why-flat-config"&gt;Why Flat Config?
&lt;/h2&gt;&lt;p&gt;The legacy &lt;code&gt;.eslintrc&lt;/code&gt; system had several problems: configuration cascading made behavior unpredictable, directory-based resolution was complex, JSON/YAML lacked support for functions and comments, and shareable configs were difficult to compose. Flat config addresses these with a single configuration file, explicit composition via JavaScript arrays, simplified plugin resolution, and full JavaScript-native syntax.&lt;/p&gt;</description></item><item><title>JavaScript Event Loop Deep Dive: Microtasks, Macrotasks, and Beyond</title><link>https://takao.blog/en/web/js-event-loop/</link><pubDate>Mon, 19 Feb 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-event-loop/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post JavaScript Event Loop Deep Dive: Microtasks, Macrotasks, and Beyond" /&gt;&lt;p&gt;The JavaScript event loop is one of the most important yet misunderstood concepts in the language. Despite JavaScript being single-threaded, its event loop enables non-blocking concurrency through a sophisticated queue system. This article builds a complete mental model of how JavaScript handles asynchronous execution, from the call stack to the microtask queue and everything in between.&lt;/p&gt;
&lt;h2 id="the-call-stack-and-execution-model"&gt;The Call Stack and Execution Model
&lt;/h2&gt;&lt;p&gt;JavaScript uses a call stack with a LIFO (Last In, First Out) structure. When a function is called, a new stack frame is pushed onto the stack. When the function returns, the frame is popped off. The key principle is run-to-completion: each function runs to completion before any other code can interrupt it.&lt;/p&gt;</description></item><item><title>Vite Plugin Development: From Zero to Production</title><link>https://takao.blog/en/web/vite-plugin-dev/</link><pubDate>Mon, 05 Feb 2024 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/vite-plugin-dev/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Vite Plugin Development: From Zero to Production" /&gt;&lt;p&gt;Vite&amp;rsquo;s plugin system is one of its most powerful features, allowing developers to extend and customize the build pipeline. Whether you need to transform file types, inject build-time constants, or integrate with other tools, the Vite plugin API gives you full control.&lt;/p&gt;
&lt;h2 id="understanding-vites-plugin-system"&gt;Understanding Vite&amp;rsquo;s Plugin System
&lt;/h2&gt;&lt;p&gt;Vite plugins are objects with hook functions that execute at specific points in the build lifecycle. Plugins operate in three phases: serve (dev server), build (production), and SSR. A basic plugin looks like this:&lt;/p&gt;</description></item><item><title>Node.js Streams: Practical Guide for Data Processing</title><link>https://takao.blog/en/web/nodejs-streams/</link><pubDate>Wed, 20 Dec 2023 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/nodejs-streams/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Node.js Streams: Practical Guide for Data Processing" /&gt;&lt;p&gt;Node.js streams are one of the most powerful yet underutilized features of the platform. They enable processing data piece by piece as it arrives, rather than loading entire datasets into memory. This makes them essential for working with large files, network communication, and real-time data transformation. This guide covers stream fundamentals and practical patterns for building robust data pipelines.&lt;/p&gt;
&lt;h2 id="understanding-stream-types"&gt;Understanding Stream Types
&lt;/h2&gt;&lt;p&gt;Node.js provides four fundamental stream types, each serving a distinct role in data processing pipelines.&lt;/p&gt;</description></item><item><title>Advanced JavaScript Promise Patterns: Async Control Flow Mastery</title><link>https://takao.blog/en/web/js-promise-patterns/</link><pubDate>Tue, 05 Dec 2023 00:00:00 +0900</pubDate><guid>https://takao.blog/en/web/js-promise-patterns/</guid><description>&lt;img src="https://takao.blog/img/thumnail.webp" alt="Featured image of post Advanced JavaScript Promise Patterns: Async Control Flow Mastery" /&gt;&lt;p&gt;Promises are fundamental to modern JavaScript, but mastering asynchronous control flow requires going beyond basic &lt;code&gt;.then()&lt;/code&gt; chains. This article explores advanced Promise patterns that intermediate to senior developers need for production applications, from concurrency control to error handling and cancellation.&lt;/p&gt;
&lt;h2 id="the-promise-landscape-beyond-basics"&gt;The Promise Landscape Beyond Basics
&lt;/h2&gt;&lt;p&gt;JavaScript provides four static methods on Promise for composing async operations, each suited to different scenarios:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Method&lt;/th&gt;
					&lt;th&gt;Resolves When&lt;/th&gt;
					&lt;th&gt;Rejects When&lt;/th&gt;
					&lt;th&gt;Use Case&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;Promise.all&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;All promises resolve&lt;/td&gt;
					&lt;td&gt;Any promise rejects&lt;/td&gt;
					&lt;td&gt;Parallel API calls, all required&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;Promise.allSettled&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;All promises settle&lt;/td&gt;
					&lt;td&gt;Never&lt;/td&gt;
					&lt;td&gt;Mixed results, log all outcomes&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;Promise.race&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;First promise settles&lt;/td&gt;
					&lt;td&gt;First promise rejects&lt;/td&gt;
					&lt;td&gt;Timeout race conditions&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;&lt;code&gt;Promise.any&lt;/code&gt;&lt;/td&gt;
					&lt;td&gt;First promise resolves&lt;/td&gt;
					&lt;td&gt;All promises reject&lt;/td&gt;
					&lt;td&gt;First-successful-response pattern&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-javascript" data-lang="javascript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;results&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;await&lt;/span&gt; Promise.&lt;span style="color:#a6e22e"&gt;allSettled&lt;/span&gt;([
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fetch&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;/api/users&amp;#34;&lt;/span&gt;).&lt;span style="color:#a6e22e"&gt;then&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; =&amp;gt; &lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;json&lt;/span&gt;()),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fetch&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;/api/posts&amp;#34;&lt;/span&gt;).&lt;span style="color:#a6e22e"&gt;then&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; =&amp;gt; &lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;json&lt;/span&gt;()),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fetch&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;/api/comments&amp;#34;&lt;/span&gt;).&lt;span style="color:#a6e22e"&gt;then&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; =&amp;gt; &lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;json&lt;/span&gt;()),
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;]);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;const&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;successful&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;results&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;filter&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; =&amp;gt; &lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;status&lt;/span&gt; &lt;span style="color:#f92672"&gt;===&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;fulfilled&amp;#34;&lt;/span&gt;).&lt;span style="color:#a6e22e"&gt;map&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; =&amp;gt; &lt;span style="color:#a6e22e"&gt;r&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;value&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;Promise.allSettled&lt;/code&gt; is particularly useful when you need to process partial results even if some operations fail, such as batch data synchronization where individual record failures should not abort the entire batch.&lt;/p&gt;</description></item></channel></rss>