From eabb75cea8d46fcfb185ac0f0c2af18f434ee0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Tue, 29 Jul 2025 22:54:16 +0100 Subject: [PATCH] lib: prefer AsyncIteratorPrototype primordial PR-URL: https://github.com/nodejs/node/pull/59097 Reviewed-By: Jordan Harband Reviewed-By: Zeyu "Alex" Yang Reviewed-By: Antoine du Hamel Reviewed-By: Luigi Pinca Reviewed-By: Moshe Atlow --- lib/events.js | 4 +--- lib/internal/freeze_intrinsics.js | 6 ++---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/events.js b/lib/events.js index 1555994df69..1c732802ef2 100644 --- a/lib/events.js +++ b/lib/events.js @@ -28,6 +28,7 @@ const { ArrayPrototypeSlice, ArrayPrototypeSplice, ArrayPrototypeUnshift, + AsyncIteratorPrototype, Boolean, Error, ErrorCaptureStackTrace, @@ -1000,9 +1001,6 @@ async function once(emitter, name, options = kEmptyObject) { }); } -const AsyncIteratorPrototype = ObjectGetPrototypeOf( - ObjectGetPrototypeOf(async function* () {}).prototype); - function createIterResult(value, done) { return { value, done }; } diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index ac7723b528e..1d793d719f5 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -31,6 +31,7 @@ const { ArrayPrototype, ArrayPrototypeForEach, ArrayPrototypePush, + AsyncIteratorPrototype, Atomics, BigInt, BigInt64Array, @@ -212,10 +213,7 @@ module.exports = function() { // 27 Control Abstraction Objects // 27.1 Iteration IteratorPrototype, // 27.1.2 IteratorPrototype - // 27.1.3 AsyncIteratorPrototype - ObjectGetPrototypeOf(ObjectGetPrototypeOf(ObjectGetPrototypeOf( - (async function*() {})(), - ))), + AsyncIteratorPrototype, // 27.1.3 AsyncIteratorPrototype PromisePrototype, // 27.2 // Other APIs / Web Compatibility