1
- 'use strict ';
1
+ import globals from 'globals ';
2
2
3
3
// These are string replacements specific to Node.js API docs for anchor IDs
4
4
export const DOC_API_SLUGS_REPLACEMENTS = [
@@ -71,15 +71,20 @@ export const DOC_API_HEADING_TYPES = [
71
71
72
72
// This is a mapping for types within the Markdown content and their respective
73
73
// JavaScript primitive types within the MDN JavaScript docs
74
- // @see DOC_MDN_BASE_URL_JS_PRIMITIVES
74
+ // @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#primitive_values
75
75
export const DOC_TYPES_MAPPING_PRIMITIVES = {
76
- boolean : 'Boolean' ,
77
- integer : 'Number' , // Not a primitive, used for clarification.
78
- null : 'Null' ,
79
- number : 'Number' ,
80
- string : 'String' ,
81
- symbol : 'Symbol' ,
82
- undefined : 'Undefined' ,
76
+ ...Object . fromEntries (
77
+ [
78
+ 'null' ,
79
+ 'undefined' ,
80
+ 'boolean' ,
81
+ 'number' ,
82
+ 'bigint' ,
83
+ 'string' ,
84
+ 'symbol' ,
85
+ ] . map ( e => [ e , e ] )
86
+ ) ,
87
+ integer : 'number' ,
83
88
} ;
84
89
85
90
// This is a mapping for types within the Markdown content and their respective
@@ -88,45 +93,15 @@ export const DOC_TYPES_MAPPING_PRIMITIVES = {
88
93
export const DOC_TYPES_MAPPING_GLOBALS = {
89
94
...Object . fromEntries (
90
95
[
91
- 'AggregateError' ,
92
- 'Array' ,
93
- 'ArrayBuffer' ,
94
- 'DataView' ,
95
- 'Date' ,
96
- 'Error' ,
97
- 'EvalError' ,
98
- 'Function' ,
99
- 'Map' ,
100
- 'NaN' ,
101
- 'Object' ,
102
- 'Promise' ,
103
- 'Proxy' ,
104
- 'RangeError' ,
105
- 'ReferenceError' ,
106
- 'RegExp' ,
107
- 'Set' ,
108
- 'SharedArrayBuffer' ,
109
- 'SyntaxError' ,
110
- 'Symbol' ,
111
- 'TypeError' ,
112
- 'URIError' ,
113
- 'WeakMap' ,
114
- 'WeakSet' ,
115
-
116
- 'TypedArray' ,
117
- 'Float16Array' ,
118
- 'Float32Array' ,
119
- 'Float64Array' ,
120
- 'Int8Array' ,
121
- 'Int16Array' ,
122
- 'Int32Array' ,
123
- 'Uint8Array' ,
124
- 'Uint8ClampedArray' ,
125
- 'Uint16Array' ,
126
- 'Uint32Array' ,
96
+ // This is updated with every ES-spec, so, as long as the
97
+ // `globals` package is up-to-date, so will our globals
98
+ // list.
99
+ ...Object . keys ( globals . builtin ) ,
100
+ 'AsyncGeneratorFunction' ,
101
+ 'AsyncIterator' ,
102
+ 'AsyncFunction' ,
127
103
] . map ( e => [ e , e ] )
128
104
) ,
129
- bigint : 'BigInt' ,
130
105
'WebAssembly.Instance' : 'WebAssembly/Instance' ,
131
106
} ;
132
107
@@ -331,18 +306,12 @@ export const DOC_TYPES_MAPPING_OTHER = {
331
306
332
307
ArrayBufferView : `${ DOC_MDN_BASE_URL } /API/ArrayBufferView` ,
333
308
334
- AsyncIterator : 'https://tc39.github.io/ecma262/#sec-asynciterator-interface' ,
335
309
AsyncIterable : 'https://tc39.github.io/ecma262/#sec-asynciterable-interface' ,
336
- AsyncFunction : 'https://tc39.es/ecma262/#sec-async-function-constructor' ,
337
310
338
311
'Module Namespace Object' :
339
312
'https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects' ,
340
313
341
- AsyncGeneratorFunction :
342
- 'https://tc39.es/proposal-async-iteration/#sec-asyncgeneratorfunction-constructor' ,
343
-
344
314
Iterable : `${ DOC_MDN_BASE_URL_JS } Reference/Iteration_protocols#The_iterable_protocol` ,
345
- Iterator : `${ DOC_MDN_BASE_URL_JS } Reference/Iteration_protocols#The_iterator_protocol` ,
346
315
347
316
CloseEvent : `${ DOC_MDN_BASE_URL } /API/CloseEvent` ,
348
317
EventSource : `${ DOC_MDN_BASE_URL } /API/EventSource` ,
0 commit comments