23
23
'use strict' ;
24
24
25
25
const {
26
+ AggregateError,
27
+ AggregateErrorPrototype,
26
28
Array,
27
29
ArrayBuffer,
28
30
ArrayBufferPrototype,
31
+ ArrayIteratorPrototype,
29
32
ArrayPrototype,
30
33
ArrayPrototypeForEach,
31
34
ArrayPrototypePush,
@@ -45,6 +48,8 @@ const {
45
48
ErrorPrototype,
46
49
EvalError,
47
50
EvalErrorPrototype,
51
+ FinalizationRegistry,
52
+ FinalizationRegistryPrototype,
48
53
Float32Array,
49
54
Float32ArrayPrototype,
50
55
Float64Array,
@@ -84,9 +89,12 @@ const {
84
89
Set,
85
90
SetPrototype,
86
91
String,
92
+ StringIteratorPrototype,
87
93
StringPrototype,
88
94
Symbol,
89
95
SymbolIterator,
96
+ SymbolMatchAll,
97
+ SymbolPrototype,
90
98
SyntaxError,
91
99
SyntaxErrorPrototype,
92
100
TypeError,
@@ -105,12 +113,15 @@ const {
105
113
URIErrorPrototype,
106
114
WeakMap,
107
115
WeakMapPrototype,
116
+ WeakRef,
117
+ WeakRefPrototype,
108
118
WeakSet,
109
119
WeakSetPrototype,
110
120
decodeURI,
111
121
decodeURIComponent,
112
122
encodeURI,
113
123
encodeURIComponent,
124
+ globalThis,
114
125
} = primordials ;
115
126
116
127
module . exports = function ( ) {
@@ -124,52 +135,38 @@ module.exports = function() {
124
135
} = require ( 'timers' ) ;
125
136
126
137
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 ,
155
146
EvalErrorPrototype ,
156
147
RangeErrorPrototype ,
157
148
ReferenceErrorPrototype ,
158
149
SyntaxErrorPrototype ,
159
150
TypeErrorPrototype ,
160
151
URIErrorPrototype ,
161
152
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
165
157
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 ] ( ) ) ,
169
164
170
- // 22 Indexed Collections
171
- ArrayPrototype , // 22.1
165
+ // 23 Indexed Collections
166
+ ArrayPrototype , // 23.1
167
+ ArrayIteratorPrototype , // 23.1.5
172
168
169
+ TypedArrayPrototype , // 23.2
173
170
Int8ArrayPrototype ,
174
171
Uint8ArrayPrototype ,
175
172
Uint8ClampedArrayPrototype ,
@@ -182,55 +179,50 @@ module.exports = function() {
182
179
BigInt64ArrayPrototype ,
183
180
BigUint64ArrayPrototype ,
184
181
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
195
209
196
210
// Other APIs / Web Compatibility
197
211
console . Console . prototype ,
198
- BigIntPrototype ,
199
212
WebAssembly . Module . prototype ,
200
213
WebAssembly . Instance . prototype ,
201
214
WebAssembly . Table . prototype ,
202
215
WebAssembly . Memory . prototype ,
203
216
WebAssembly . CompileError . prototype ,
204
217
WebAssembly . LinkError . prototype ,
205
218
WebAssembly . RuntimeError . prototype ,
206
- SharedArrayBuffer . prototype ,
207
219
] ;
208
220
const intrinsics = [
209
- // Anonymous Intrinsics
210
- // ThrowTypeError
221
+ // 10.2.4.1 ThrowTypeError
211
222
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 ,
232
223
233
- // 18 The Global Object
224
+ // 19 The Global Object
225
+ // 19.2 Function Properties of the Global Object
234
226
eval ,
235
227
// eslint-disable-next-line node-core/prefer-primordials
236
228
isFinite ,
@@ -240,38 +232,46 @@ module.exports = function() {
240
232
parseFloat ,
241
233
// eslint-disable-next-line node-core/prefer-primordials
242
234
parseInt ,
235
+ // 19.2.6 URI Handling Functions
243
236
decodeURI ,
244
237
decodeURIComponent ,
245
238
encodeURI ,
246
239
encodeURIComponent ,
247
240
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
253
246
254
- Error , // 19.5
247
+ Error , // 20.5
248
+ AggregateError ,
255
249
EvalError ,
256
250
RangeError ,
257
251
ReferenceError ,
258
252
SyntaxError ,
259
253
TypeError ,
260
254
URIError ,
261
255
262
- // 20 Numbers and Dates
263
- Number , // 20.1
256
+ // 21 Numbers and Dates
257
+ Number , // 21.1
258
+ BigInt , // 21.2
264
259
// 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 ,
275
275
Int8Array ,
276
276
Uint8Array ,
277
277
Uint8ClampedArray ,
@@ -284,23 +284,47 @@ module.exports = function() {
284
284
BigInt64Array ,
285
285
BigUint64Array ,
286
286
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
296
302
// 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 ( ) { } ) ,
299
323
300
- // 26 Reflection
324
+ // 28 Reflection
301
325
// eslint-disable-next-line node-core/prefer-primordials
302
- Reflect , // 26 .1
303
- Proxy , // 26 .2
326
+ Reflect , // 28 .1
327
+ Proxy , // 28 .2
304
328
305
329
// B.2.1
306
330
escape ,
@@ -314,10 +338,7 @@ module.exports = function() {
314
338
setInterval ,
315
339
setTimeout ,
316
340
console ,
317
- BigInt ,
318
- Atomics ,
319
341
WebAssembly ,
320
- SharedArrayBuffer ,
321
342
] ;
322
343
323
344
if ( typeof Intl !== 'undefined' ) {
@@ -337,6 +358,13 @@ module.exports = function() {
337
358
const frozenSet = new WeakSet ( ) ;
338
359
ArrayPrototypeForEach ( intrinsics , deepFreeze ) ;
339
360
361
+ // 19.1 Value Properties of the Global Object
362
+ ObjectDefineProperty ( globalThis , 'globalThis' , {
363
+ configurable : false ,
364
+ writable : false ,
365
+ value : globalThis ,
366
+ } ) ;
367
+
340
368
// Objects that are deeply frozen.
341
369
function deepFreeze ( root ) {
342
370
/**
0 commit comments