このチャプターの目次
- 第1章 - API を提供する環境と実行メカニズム
- 第2章 - Promise インスタンスと連鎖
- Promise の基本概念
- Promise コンストラクタと Executor 関数
- コールバック関数の同期実行と非同期実行
- resolve 関数と reject 関数の使い方
- 複数の Promise を走らせる
- then メソッドは常に新しい Promise を返す
- Promise chain で値を繋ぐ
- then メソッドのコールバックで Promise インスタンスを返す
- Promise chain はネストさせない
- コールバックで副作用となる非同期処理
- アロー関数で return を省略する
- catch メソッドと finally メソッド
- 古い非同期 API を Promise でラップする
- イベントループは内部にネストしたループがある
- 第3章 - async 関数と await 式の挙動
- 第4章 - 制御と型注釈
- 第5章 - 仕様およびその他の番外編
- その他
第1章 - API を提供する環境と実行メカニズム
非同期 API と環境
- JavaScriptとは · JavaScript Primer #jsprimer
- Async Await JavaScript Tutorial – How to Wait for a Function to Finish in JS
- WinterCG(Web-interoperable Runtimes Community Group)
- Inside look at modern web browser (part 2) - Chrome Developers
- What the heck is the event loop anyway? – Philip Roberts
- Angular Basics: Introduction to Processes, Threads—Web UI
- A Taste of JavaScript's New Parallel Primitives - Mozilla Hacks - the Web developer blog
MDN
- How to use promises - Learn web development | MDN
- サードパーティ API(Third-party APIs)
- プロミスの使用 - JavaScript | MDN
- Web API | MDN
- Web Worker の使用 - Web API | MDN
- Atomics - JavaScript | MDN
- SharedArrayBuffer - JavaScript | MDN
同期 API とブロッキング
イベントループの概要と注意点
- Writing a JavaScript framework - Execution timing, beyond setTimeout - RisingStack Engineering
- Tasks, microtasks, queues and schedules - JakeArchibald.com
タスクキューとマイクロタスクキュー
MDN
- setInterval() - Web APIs | MDN
- Using microtasks in JavaScript with queueMicrotask() - Web APIs | MDN
- queueMicrotask() - Web APIs | MDN
- JavaScript で queueMicrotask() によるマイクロタスクの使用 - Web API | MDN
- MutationObserver() - Web APIs | MDN
- In depth: Microtasks and the JavaScript runtime environment - Web APIs | MDN
V8 エンジンについて
- V8 JavaScript engine
- JavaScript V8 Engine Explained | HackerNoon
- JS Visualizer 9000
- ブラウザ JavaScript / Node.js の仕組みを知ろう! ~トラブルに迅速に立ち向かえる様に - Qiita
- JavaScriptがブラウザでどのように動くのか | メルカリエンジニアリング
- GoogleChromeLabs/jsvu: JavaScript (engine) Version Updater
- fishで「パスを通す」ための最終解答
- Using d8 · V8
MDN
コールスタックと実行コンテキスト
- JavaScript Execution Context – How JS Works Behind The Scenes
- zero-cost async stack traces // slidr.io
Spec
MDN
それぞれのイベントループ
- Timers | Node.js v18.4.0 Documentation
- timers: run nextTicks after each immediate and timer by apapirovski · Pull Request #22842 · nodejs/node
- Microtask queue is not handled correctly in Deno · Issue #11731 · denoland/deno
- Faster async functions and promises · V8
- JS Visualizer 9000
- Further Adventures of the Event Loop - Erin Zimmer - JSConf EU 2018 - YouTube
- libevent
- Blink Scheduler - Google ドキュメント
- Blink Scheduler
- Scheduling docs
- Prioritize important incoming tasks in renderers - Google ドキュメント
- JavaScript のスレッド並列実行環境
- Rendering Performance
- How Blink works - Google ドキュメント
- Life of a Pixel - Google スライド
- Jake Archibald: In The Loop - setTimeout, micro tasks, requestAnimationFrame, requestIdleCallback, … - YouTube
- 深入探究 eventloop 与浏览器渲染的时序问题 - 404Forest
- Timing of microtask triggered from requestAnimationFrame · Issue #2637 · whatwg/html
- The Node.js Event Loop, Timers, and process.nextTick() | Node.js
- 2016 Node Interactive.pdf - Google ドライブ
- timers: run nextTicks after each immediate and timer by apapirovski · Pull Request #22842 · nodejs/node
- Event Loop performance different in different version · Issue #3512 · nodejs/help
- Learn Node.js, Unit 5: The event loop - YouTube
- IBM Developer
Spec
MDN
- プロミスの使用 - JavaScript | MDN
- Blob.text() - Web API | MDN
- The event loop - JavaScript | MDN
- Overview of the RenderingNG architecture - Chrome Developers
- Web Worker の使用 - Web API | MDN
第2章 - Promise インスタンスと連鎖
Promise の基本概念
- promises-unwrapping/states-and-fates.md at master · domenic/promises-unwrapping
- What is the correct terminology for javascript promises - Stack Overflow
Promise コンストラクタと Executor 関数
- When to use a function declaration vs. a function expression
- アロー関数 (arrow function) | TypeScript入門『サバイバルTypeScript』
- javascript - Using _ (underscore) variable with arrow functions in ES6/Typescript - Stack Overflow
- JavaScript: 通常の関数とアロー関数の違いは「書き方だけ」ではない。異なる性質が10個ほどある。 - Qiita
- 従来の関数とアロー関数の違い | TypeScript入門『サバイバルTypeScript』
MDN
コールバック関数の同期実行と非同期実行
MDN
resolve 関数と reject 関数の使い方
複数の Promise を走らせる
then メソッドは常に新しい Promise を返す
Promise chain で値を繋ぐ
then メソッドのコールバックで Promise インスタンスを返す
MDN
Promise chain はネストさせない
MDN
コールバックで副作用となる非同期処理
アロー関数で return を省略する
catch メソッドと finally メソッド
MDN
古い非同期 API を Promise でラップする
MDN
イベントループは内部にネストしたループがある
- Writing a JavaScript framework - Execution timing, beyond setTimeout - RisingStack Engineering
- Tasks, microtasks, queues and schedules - JakeArchibald.com
- JavaScriptの非同期処理をじっくり理解する (1) 実行モデルとタスクキュー
- Further Adventures of the Event Loop - Erin Zimmer - JSConf EU 2018 - YouTube
第3章 - async 関数と await 式の挙動
Promise chain から async 関数へ
V8 エンジンによる async/await の内部変換
- Faster async functions and promises · V8
- Normative: Reduce the number of ticks in async/await by MayaLekova · Pull Request #1250 · tc39/ecma262
- Zero-cost async stack traces - Google ドキュメント
- 徹底解説! return promiseとreturn await promiseの違い
- Resolve Javascript Promise outside the Promise constructor scope - Stack Overflow
- return と return await の3つの違い
- JavaScriptの非同期処理をじっくり理解する (3) async/await
- node.js - JS Promise's inconsistent execution order between nodejs versions - Stack Overflow
Top-level await
MDN
第4章 - 制御と型注釈
Promise の静的メソッドと並列化
MDN
await 式の配置による制御
- require-await | deno_lint docs
- JavaScriptの非同期処理をじっくり理解する (4) AbortSignal, Event, Async Context
- オブジェクト · JavaScript Primer #jsprimer
MDN
反復処理の制御
MDN
イテレータとイテラブルとジェネレータ関数
MDN
- 反復処理プロトコル - JavaScript | MDN
- 計算プロパティ名 - JavaScript | MDN
- for...of - JavaScript | MDN
- 反復可能オブジェクトを期待する構文 - JavaScript | MDN
- Promise.all() - JavaScript | MDN
- Symbol.asyncIterator - JavaScript | MDN
- AsyncGenerator - JavaScript | MDN
TypeScript における Promise の型注釈
- Promise / async / await | TypeScript入門『サバイバルTypeScript』
- タプル (tuple) | TypeScript入門『サバイバルTypeScript』
- イベントループと TypeScript の型から理解する非同期処理
- JavaScript - TypeScript Deep Dive 日本語版
- TypeScript: Documentation - TypeScript for JavaScript Programmers
- TypeScript: Documentation - Generics
- deno lint rule no-inferrable-types
- deno lint rule no-explicit-any
- Async Await try-catch hell - YouTube
第5章 - 仕様およびその他の番外編
Promise.prototype.then の仕様挙動
- Creating a JavaScript promise from scratch, Part 1: Constructor - Human Who Codes
- Creating a JavaScript promise from scratch, Part 2: Resolving to a promise - Human Who Codes
- Creating a JavaScript promise from scratch, Part 3: then(), catch(), and finally() - Human Who Codes
- Creating a JavaScript promise from scratch, Part 4: Promise.resolve() and Promise.reject() - Human Who Codes
- humanwhocodes/pledge: A custom promise implementation for JavaScript
- Understanding the ECMAScript spec, part 1
- How to Read the ECMAScript Specification
Promise chain と async/await の仕様比較
- Normative: Reduce the number of ticks in async/await by MayaLekova · Pull Request #1250 · tc39/ecma262
- tc39/proposal-faster-promise-adoption: Reduce the number of microtask ticks required to adopt the state of a promise