2323'use strict' ;
2424
2525const {
26+ AggregateError,
27+ AggregateErrorPrototype,
2628 Array,
2729 ArrayBuffer,
2830 ArrayBufferPrototype,
31+ ArrayIteratorPrototype,
2932 ArrayPrototype,
3033 ArrayPrototypeForEach,
3134 ArrayPrototypePush,
@@ -45,6 +48,8 @@ const {
4548 ErrorPrototype,
4649 EvalError,
4750 EvalErrorPrototype,
51+ FinalizationRegistry,
52+ FinalizationRegistryPrototype,
4853 Float32Array,
4954 Float32ArrayPrototype,
5055 Float64Array,
@@ -84,9 +89,12 @@ const {
8489 Set,
8590 SetPrototype,
8691 String,
92+ StringIteratorPrototype,
8793 StringPrototype,
8894 Symbol,
8995 SymbolIterator,
96+ SymbolMatchAll,
97+ SymbolPrototype,
9098 SyntaxError,
9199 SyntaxErrorPrototype,
92100 TypeError,
@@ -105,12 +113,15 @@ const {
105113 URIErrorPrototype,
106114 WeakMap,
107115 WeakMapPrototype,
116+ WeakRef,
117+ WeakRefPrototype,
108118 WeakSet,
109119 WeakSetPrototype,
110120 decodeURI,
111121 decodeURIComponent,
112122 encodeURI,
113123 encodeURIComponent,
124+ globalThis,
114125} = primordials ;
115126
116127module . exports = function ( ) {
@@ -124,52 +135,38 @@ module.exports = function() {
124135 } = require ( 'timers' ) ;
125136
126137 const intrinsicPrototypes = [
127- // Anonymous Intrinsics
128- // IteratorPrototype
129- ObjectGetPrototypeOf (
130- ObjectGetPrototypeOf ( new Array ( ) [ SymbolIterator ] ( ) )
131- ) ,
132- // ArrayIteratorPrototype
133- ObjectGetPrototypeOf ( new Array ( ) [ SymbolIterator ] ( ) ) ,
134- // StringIteratorPrototype
135- ObjectGetPrototypeOf ( new String ( ) [ SymbolIterator ] ( ) ) ,
136- // MapIteratorPrototype
137- ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
138- // SetIteratorPrototype
139- ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
140- // GeneratorFunction
141- ObjectGetPrototypeOf ( function * ( ) { } ) ,
142- // AsyncFunction
143- ObjectGetPrototypeOf ( async function ( ) { } ) ,
144- // AsyncGeneratorFunction
145- ObjectGetPrototypeOf ( async function * ( ) { } ) ,
146- // TypedArray
147- TypedArrayPrototype ,
148-
149- // 19 Fundamental Objects
150- ObjectPrototype , // 19.1
151- FunctionPrototype , // 19.2
152- BooleanPrototype , // 19.3
153-
154- ErrorPrototype , // 19.5
138+ // 20 Fundamental Objects
139+ ObjectPrototype , // 20.1
140+ FunctionPrototype , // 20.2
141+ BooleanPrototype , // 20.3
142+ SymbolPrototype , // 20.4
143+
144+ ErrorPrototype , // 20.5
145+ AggregateErrorPrototype ,
155146 EvalErrorPrototype ,
156147 RangeErrorPrototype ,
157148 ReferenceErrorPrototype ,
158149 SyntaxErrorPrototype ,
159150 TypeErrorPrototype ,
160151 URIErrorPrototype ,
161152
162- // 20 Numbers and Dates
163- NumberPrototype , // 20.1
164- DatePrototype , // 20.3
153+ // 21 Numbers and Dates
154+ NumberPrototype , // 21.1
155+ BigIntPrototype , // 21.2
156+ DatePrototype , // 21.4
165157
166- // 21 Text Processing
167- StringPrototype , // 21.1
168- RegExpPrototype , // 21.2
158+ // 22 Text Processing
159+ StringPrototype , // 22.1
160+ StringIteratorPrototype , // 22.1.5
161+ RegExpPrototype , // 22.2
162+ // 22.2.7 RegExpStringIteratorPrototype
163+ ObjectGetPrototypeOf ( / e / [ SymbolMatchAll ] ( ) ) ,
169164
170- // 22 Indexed Collections
171- ArrayPrototype , // 22.1
165+ // 23 Indexed Collections
166+ ArrayPrototype , // 23.1
167+ ArrayIteratorPrototype , // 23.1.5
172168
169+ TypedArrayPrototype , // 23.2
173170 Int8ArrayPrototype ,
174171 Uint8ArrayPrototype ,
175172 Uint8ClampedArrayPrototype ,
@@ -182,55 +179,50 @@ module.exports = function() {
182179 BigInt64ArrayPrototype ,
183180 BigUint64ArrayPrototype ,
184181
185- // 23 Keyed Collections
186- MapPrototype , // 23.1
187- SetPrototype , // 23.2
188- WeakMapPrototype , // 23.3
189- WeakSetPrototype , // 23.4
190-
191- // 24 Structured Data
192- ArrayBufferPrototype , // 24.1
193- DataViewPrototype , // 24.3
194- PromisePrototype , // 25.4
182+ // 24 Keyed Collections
183+ MapPrototype , // 24.1
184+ // 24.1.5 MapIteratorPrototype
185+ ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
186+ SetPrototype , // 24.2
187+ // 24.2.5 SetIteratorPrototype
188+ ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
189+ WeakMapPrototype , // 24.3
190+ WeakSetPrototype , // 24.4
191+
192+ // 25 Structured Data
193+ ArrayBufferPrototype , // 25.1
194+ SharedArrayBuffer . prototype , // 25.2
195+ DataViewPrototype , // 25.3
196+
197+ // 26 Managing Memory
198+ WeakRefPrototype , // 26.1
199+ FinalizationRegistryPrototype , // 26.2
200+
201+ // 27 Control Abstraction Objects
202+ // 27.1 Iteration
203+ ObjectGetPrototypeOf ( ArrayIteratorPrototype ) , // 27.1.2 IteratorPrototype
204+ // 27.1.3 AsyncIteratorPrototype
205+ ObjectGetPrototypeOf ( ObjectGetPrototypeOf ( ObjectGetPrototypeOf (
206+ ( async function * ( ) { } ) ( )
207+ ) ) ) ,
208+ PromisePrototype , // 27.2
195209
196210 // Other APIs / Web Compatibility
197211 console . Console . prototype ,
198- BigIntPrototype ,
199212 WebAssembly . Module . prototype ,
200213 WebAssembly . Instance . prototype ,
201214 WebAssembly . Table . prototype ,
202215 WebAssembly . Memory . prototype ,
203216 WebAssembly . CompileError . prototype ,
204217 WebAssembly . LinkError . prototype ,
205218 WebAssembly . RuntimeError . prototype ,
206- SharedArrayBuffer . prototype ,
207219 ] ;
208220 const intrinsics = [
209- // Anonymous Intrinsics
210- // ThrowTypeError
221+ // 10.2.4.1 ThrowTypeError
211222 ObjectGetOwnPropertyDescriptor ( FunctionPrototype , 'caller' ) . get ,
212- // IteratorPrototype
213- ObjectGetPrototypeOf (
214- ObjectGetPrototypeOf ( new Array ( ) [ SymbolIterator ] ( ) )
215- ) ,
216- // ArrayIteratorPrototype
217- ObjectGetPrototypeOf ( new Array ( ) [ SymbolIterator ] ( ) ) ,
218- // StringIteratorPrototype
219- ObjectGetPrototypeOf ( new String ( ) [ SymbolIterator ] ( ) ) ,
220- // MapIteratorPrototype
221- ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
222- // SetIteratorPrototype
223- ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
224- // GeneratorFunction
225- ObjectGetPrototypeOf ( function * ( ) { } ) ,
226- // AsyncFunction
227- ObjectGetPrototypeOf ( async function ( ) { } ) ,
228- // AsyncGeneratorFunction
229- ObjectGetPrototypeOf ( async function * ( ) { } ) ,
230- // TypedArray
231- TypedArray ,
232223
233- // 18 The Global Object
224+ // 19 The Global Object
225+ // 19.2 Function Properties of the Global Object
234226 eval ,
235227 // eslint-disable-next-line node-core/prefer-primordials
236228 isFinite ,
@@ -240,38 +232,46 @@ module.exports = function() {
240232 parseFloat ,
241233 // eslint-disable-next-line node-core/prefer-primordials
242234 parseInt ,
235+ // 19.2.6 URI Handling Functions
243236 decodeURI ,
244237 decodeURIComponent ,
245238 encodeURI ,
246239 encodeURIComponent ,
247240
248- // 19 Fundamental Objects
249- Object , // 19 .1
250- Function , // 19 .2
251- Boolean , // 19 .3
252- Symbol , // 19 .4
241+ // 20 Fundamental Objects
242+ Object , // 20 .1
243+ Function , // 20 .2
244+ Boolean , // 20 .3
245+ Symbol , // 20 .4
253246
254- Error , // 19.5
247+ Error , // 20.5
248+ AggregateError ,
255249 EvalError ,
256250 RangeError ,
257251 ReferenceError ,
258252 SyntaxError ,
259253 TypeError ,
260254 URIError ,
261255
262- // 20 Numbers and Dates
263- Number , // 20.1
256+ // 21 Numbers and Dates
257+ Number , // 21.1
258+ BigInt , // 21.2
264259 // eslint-disable-next-line node-core/prefer-primordials
265- Math , // 20.2
266- Date , // 20.3
267-
268- // 21 Text Processing
269- String , // 21.1
270- RegExp , // 21.2
271-
272- // 22 Indexed Collections
273- Array , // 22.1
274-
260+ Math , // 21.3
261+ Date , // 21.4
262+
263+ // 22 Text Processing
264+ String , // 22.1
265+ StringIteratorPrototype , // 22.1.5
266+ RegExp , // 22.2
267+ // 22.2.7 RegExpStringIteratorPrototype
268+ ObjectGetPrototypeOf ( / e / [ SymbolMatchAll ] ( ) ) ,
269+
270+ // 23 Indexed Collections
271+ Array , // 23.1
272+ ArrayIteratorPrototype , // 23.1.5
273+ // 23.2 TypedArray
274+ TypedArray ,
275275 Int8Array ,
276276 Uint8Array ,
277277 Uint8ClampedArray ,
@@ -284,23 +284,47 @@ module.exports = function() {
284284 BigInt64Array ,
285285 BigUint64Array ,
286286
287- // 23 Keyed Collections
288- Map , // 23.1
289- Set , // 23.2
290- WeakMap , // 23.3
291- WeakSet , // 23.4
292-
293- // 24 Structured Data
294- ArrayBuffer , // 24.1
295- DataView , // 24.3
287+ // 24 Keyed Collections
288+ Map , // 24.1
289+ // 24.1.5 MapIteratorPrototype
290+ ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
291+ Set , // 24.2
292+ // 24.2.5 SetIteratorPrototype
293+ ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
294+ WeakMap , // 24.3
295+ WeakSet , // 24.4
296+
297+ // 25 Structured Data
298+ ArrayBuffer , // 25.1
299+ SharedArrayBuffer , // 25.2
300+ DataView , // 25.3
301+ Atomics , // 25.4
296302 // eslint-disable-next-line node-core/prefer-primordials
297- JSON , // 24.5
298- Promise , // 25.4
303+ JSON , // 25.5
304+
305+ // 26 Managing Memory
306+ WeakRef , // 26.1
307+ FinalizationRegistry , // 26.2
308+
309+ // 27 Control Abstraction Objects
310+ // 27.1 Iteration
311+ ObjectGetPrototypeOf ( ArrayIteratorPrototype ) , // 27.1.2 IteratorPrototype
312+ // 27.1.3 AsyncIteratorPrototype
313+ ObjectGetPrototypeOf ( ObjectGetPrototypeOf ( ObjectGetPrototypeOf (
314+ ( async function * ( ) { } ) ( )
315+ ) ) ) ,
316+ Promise , // 27.2
317+ // 27.3 GeneratorFunction
318+ ObjectGetPrototypeOf ( function * ( ) { } ) ,
319+ // 27.4 AsyncGeneratorFunction
320+ ObjectGetPrototypeOf ( async function * ( ) { } ) ,
321+ // 27.7 AsyncFunction
322+ ObjectGetPrototypeOf ( async function ( ) { } ) ,
299323
300- // 26 Reflection
324+ // 28 Reflection
301325 // eslint-disable-next-line node-core/prefer-primordials
302- Reflect , // 26 .1
303- Proxy , // 26 .2
326+ Reflect , // 28 .1
327+ Proxy , // 28 .2
304328
305329 // B.2.1
306330 escape ,
@@ -314,10 +338,7 @@ module.exports = function() {
314338 setInterval ,
315339 setTimeout ,
316340 console ,
317- BigInt ,
318- Atomics ,
319341 WebAssembly ,
320- SharedArrayBuffer ,
321342 ] ;
322343
323344 if ( typeof Intl !== 'undefined' ) {
@@ -337,6 +358,13 @@ module.exports = function() {
337358 const frozenSet = new WeakSet ( ) ;
338359 ArrayPrototypeForEach ( intrinsics , deepFreeze ) ;
339360
361+ // 19.1 Value Properties of the Global Object
362+ ObjectDefineProperty ( globalThis , 'globalThis' , {
363+ configurable : false ,
364+ writable : false ,
365+ value : globalThis ,
366+ } ) ;
367+
340368 // Objects that are deeply frozen.
341369 function deepFreeze ( root ) {
342370 /**
0 commit comments