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,11 @@ const {
84
89
Set,
85
90
SetPrototype,
86
91
String,
92
+ StringIteratorPrototype,
87
93
StringPrototype,
88
94
Symbol,
89
95
SymbolIterator,
96
+ SymbolMatchAll,
90
97
SyntaxError,
91
98
SyntaxErrorPrototype,
92
99
TypeError,
@@ -105,12 +112,15 @@ const {
105
112
URIErrorPrototype,
106
113
WeakMap,
107
114
WeakMapPrototype,
115
+ WeakRef,
116
+ WeakRefPrototype,
108
117
WeakSet,
109
118
WeakSetPrototype,
110
119
decodeURI,
111
120
decodeURIComponent,
112
121
encodeURI,
113
122
encodeURIComponent,
123
+ globalThis,
114
124
} = primordials ;
115
125
116
126
module . exports = function ( ) {
@@ -124,52 +134,37 @@ module.exports = function() {
124
134
} = require ( 'timers' ) ;
125
135
126
136
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
137
+ // 21 Fundamental Objects
138
+ ObjectPrototype , // 20.1
139
+ FunctionPrototype , // 20.2
140
+ BooleanPrototype , // 20.3
153
141
154
- ErrorPrototype , // 19.5
142
+ ErrorPrototype , // 20.5
143
+ AggregateErrorPrototype ,
155
144
EvalErrorPrototype ,
156
145
RangeErrorPrototype ,
157
146
ReferenceErrorPrototype ,
158
147
SyntaxErrorPrototype ,
159
148
TypeErrorPrototype ,
160
149
URIErrorPrototype ,
161
150
162
- // 20 Numbers and Dates
163
- NumberPrototype , // 20.1
164
- DatePrototype , // 20.3
151
+ // 21 Numbers and Dates
152
+ NumberPrototype , // 21.1
153
+ BigIntPrototype , // 21.2
154
+ DatePrototype , // 21.4
165
155
166
- // 21 Text Processing
167
- StringPrototype , // 21.1
168
- RegExpPrototype , // 21.2
156
+ // 22 Text Processing
157
+ StringPrototype , // 22.1
158
+ StringIteratorPrototype , // 22.1.5
159
+ RegExpPrototype , // 22.2
160
+ // 22.2.7 RegExpStringIteratorPrototype
161
+ ObjectGetPrototypeOf ( / e / [ SymbolMatchAll ] ( ) ) ,
169
162
170
- // 22 Indexed Collections
171
- ArrayPrototype , // 22.1
163
+ // 23 Indexed Collections
164
+ ArrayPrototype , // 23.1
165
+ ArrayIteratorPrototype , // 23.1.5
172
166
167
+ TypedArrayPrototype , // 23.2
173
168
Int8ArrayPrototype ,
174
169
Uint8ArrayPrototype ,
175
170
Uint8ClampedArrayPrototype ,
@@ -182,55 +177,50 @@ module.exports = function() {
182
177
BigInt64ArrayPrototype ,
183
178
BigUint64ArrayPrototype ,
184
179
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
180
+ // 24 Keyed Collections
181
+ MapPrototype , // 24.1
182
+ // 24.1.5 MapIteratorPrototype
183
+ ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
184
+ SetPrototype , // 24.2
185
+ // 24.2.5 SetIteratorPrototype
186
+ ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
187
+ WeakMapPrototype , // 24.3
188
+ WeakSetPrototype , // 24.4
189
+
190
+ // 25 Structured Data
191
+ ArrayBufferPrototype , // 25.1
192
+ SharedArrayBuffer . prototype , // 25.2
193
+ DataViewPrototype , // 25.3
194
+
195
+ // 26 Managing Memory
196
+ WeakRefPrototype , // 26.1
197
+ FinalizationRegistryPrototype , // 26.2
198
+
199
+ // 27 Control Abstraction Objects
200
+ // 27.1 Iteration
201
+ ObjectGetPrototypeOf ( ArrayIteratorPrototype ) , // 27.1.2 IteratorPrototype
202
+ // 27.1.3 AsyncIteratorPrototype
203
+ ObjectGetPrototypeOf ( ObjectGetPrototypeOf ( ObjectGetPrototypeOf (
204
+ ( async function * ( ) { } ) ( )
205
+ ) ) ) ,
206
+ PromisePrototype , // 27.2
195
207
196
208
// Other APIs / Web Compatibility
197
209
console . Console . prototype ,
198
- BigIntPrototype ,
199
210
WebAssembly . Module . prototype ,
200
211
WebAssembly . Instance . prototype ,
201
212
WebAssembly . Table . prototype ,
202
213
WebAssembly . Memory . prototype ,
203
214
WebAssembly . CompileError . prototype ,
204
215
WebAssembly . LinkError . prototype ,
205
216
WebAssembly . RuntimeError . prototype ,
206
- SharedArrayBuffer . prototype ,
207
217
] ;
208
218
const intrinsics = [
209
- // Anonymous Intrinsics
210
- // ThrowTypeError
219
+ // 10.2.4.1 ThrowTypeError
211
220
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
221
233
- // 18 The Global Object
222
+ // 19 The Global Object
223
+ // 19.2 Function Properties of the Global Object
234
224
eval ,
235
225
// eslint-disable-next-line node-core/prefer-primordials
236
226
isFinite ,
@@ -240,38 +230,46 @@ module.exports = function() {
240
230
parseFloat ,
241
231
// eslint-disable-next-line node-core/prefer-primordials
242
232
parseInt ,
233
+ // 19.2.6 URI Handling Functions
243
234
decodeURI ,
244
235
decodeURIComponent ,
245
236
encodeURI ,
246
237
encodeURIComponent ,
247
238
248
- // 19 Fundamental Objects
249
- Object , // 19 .1
250
- Function , // 19 .2
251
- Boolean , // 19 .3
252
- Symbol , // 19 .4
239
+ // 20 Fundamental Objects
240
+ Object , // 20 .1
241
+ Function , // 20 .2
242
+ Boolean , // 20 .3
243
+ Symbol , // 20 .4
253
244
254
- Error , // 19.5
245
+ Error , // 20.5
246
+ AggregateError ,
255
247
EvalError ,
256
248
RangeError ,
257
249
ReferenceError ,
258
250
SyntaxError ,
259
251
TypeError ,
260
252
URIError ,
261
253
262
- // 20 Numbers and Dates
263
- Number , // 20.1
254
+ // 21 Numbers and Dates
255
+ Number , // 21.1
256
+ BigInt , // 21.2
264
257
// 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
-
258
+ Math , // 21.3
259
+ Date , // 21.4
260
+
261
+ // 22 Text Processing
262
+ String , // 22.1
263
+ StringIteratorPrototype , // 22.1.5
264
+ RegExp , // 22.2
265
+ // 22.2.7 RegExpStringIteratorPrototype
266
+ ObjectGetPrototypeOf ( / e / [ SymbolMatchAll ] ( ) ) ,
267
+
268
+ // 23 Indexed Collections
269
+ Array , // 23.1
270
+ ArrayIteratorPrototype , // 23.1.5
271
+ // 23.2 TypedArray
272
+ TypedArray ,
275
273
Int8Array ,
276
274
Uint8Array ,
277
275
Uint8ClampedArray ,
@@ -284,23 +282,47 @@ module.exports = function() {
284
282
BigInt64Array ,
285
283
BigUint64Array ,
286
284
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
285
+ // 24 Keyed Collections
286
+ Map , // 24.1
287
+ // 24.1.5 MapIteratorPrototype
288
+ ObjectGetPrototypeOf ( new Map ( ) [ SymbolIterator ] ( ) ) ,
289
+ Set , // 24.2
290
+ // 24.2.5 SetIteratorPrototype
291
+ ObjectGetPrototypeOf ( new Set ( ) [ SymbolIterator ] ( ) ) ,
292
+ WeakMap , // 24.3
293
+ WeakSet , // 24.4
294
+
295
+ // 25 Structured Data
296
+ ArrayBuffer , // 25.1
297
+ SharedArrayBuffer , // 25.2
298
+ DataView , // 25.3
299
+ Atomics , // 25.4
296
300
// eslint-disable-next-line node-core/prefer-primordials
297
- JSON , // 24.5
298
- Promise , // 25.4
301
+ JSON , // 25.5
302
+
303
+ // 26 Managing Memory
304
+ WeakRef , // 26.1
305
+ FinalizationRegistry , // 26.2
306
+
307
+ // 27 Control Abstraction Objects
308
+ // 27.1 Iteration
309
+ ObjectGetPrototypeOf ( ArrayIteratorPrototype ) , // 27.1.2 IteratorPrototype
310
+ // 27.1.3 AsyncIteratorPrototype
311
+ ObjectGetPrototypeOf ( ObjectGetPrototypeOf ( ObjectGetPrototypeOf (
312
+ ( async function * ( ) { } ) ( )
313
+ ) ) ) ,
314
+ Promise , // 27.2
315
+ // 27.3 GeneratorFunction
316
+ ObjectGetPrototypeOf ( function * ( ) { } ) ,
317
+ // 27.4 AsyncGeneratorFunction
318
+ ObjectGetPrototypeOf ( async function * ( ) { } ) ,
319
+ // 27.7 AsyncFunction
320
+ ObjectGetPrototypeOf ( async function ( ) { } ) ,
299
321
300
- // 26 Reflection
322
+ // 28 Reflection
301
323
// eslint-disable-next-line node-core/prefer-primordials
302
- Reflect , // 26 .1
303
- Proxy , // 26 .2
324
+ Reflect , // 28 .1
325
+ Proxy , // 28 .2
304
326
305
327
// B.2.1
306
328
escape ,
@@ -314,10 +336,7 @@ module.exports = function() {
314
336
setInterval ,
315
337
setTimeout ,
316
338
console ,
317
- BigInt ,
318
- Atomics ,
319
339
WebAssembly ,
320
- SharedArrayBuffer ,
321
340
] ;
322
341
323
342
if ( typeof Intl !== 'undefined' ) {
@@ -337,6 +356,13 @@ module.exports = function() {
337
356
const frozenSet = new WeakSet ( ) ;
338
357
ArrayPrototypeForEach ( intrinsics , deepFreeze ) ;
339
358
359
+ // 19.1 Value Properties of the Global Object
360
+ ObjectDefineProperty ( globalThis , 'globalThis' , {
361
+ configurable : false ,
362
+ writable : false ,
363
+ value : globalThis ,
364
+ } ) ;
365
+
340
366
// Objects that are deeply frozen.
341
367
function deepFreeze ( root ) {
342
368
/**
0 commit comments