|
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,62 +71,32 @@ 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 |
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', |
83 |
| -}; |
| 74 | +// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Data_structures#primitive_values |
| 75 | +export const DOC_TYPES_MAPPING_PRIMITIVES = [ |
| 76 | + 'null', |
| 77 | + 'undefined', |
| 78 | + 'boolean', |
| 79 | + 'number', |
| 80 | + 'bigint', |
| 81 | + 'string', |
| 82 | + 'symbol', |
| 83 | +]; |
84 | 84 |
|
85 | 85 | // This is a mapping for types within the Markdown content and their respective
|
86 | 86 | // JavaScript globals types within the MDN JavaScript docs
|
87 | 87 | // @see DOC_MDN_BASE_URL_JS_GLOBALS
|
88 | 88 | export const DOC_TYPES_MAPPING_GLOBALS = {
|
89 | 89 | ...Object.fromEntries(
|
90 | 90 | [
|
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', |
| 91 | + // This is updated with every ES-spec, so, as long as the |
| 92 | + // `globals` package is up-to-date, so will our globals |
| 93 | + // list. |
| 94 | + ...Object.keys(globals.builtin), |
| 95 | + 'AsyncGeneratorFunction', |
| 96 | + 'AsyncIterator', |
| 97 | + 'AsyncFunction', |
127 | 98 | ].map(e => [e, e])
|
128 | 99 | ),
|
129 |
| - bigint: 'BigInt', |
130 | 100 | 'WebAssembly.Instance': 'WebAssembly/Instance',
|
131 | 101 | };
|
132 | 102 |
|
@@ -331,18 +301,12 @@ export const DOC_TYPES_MAPPING_OTHER = {
|
331 | 301 |
|
332 | 302 | ArrayBufferView: `${DOC_MDN_BASE_URL}/API/ArrayBufferView`,
|
333 | 303 |
|
334 |
| - AsyncIterator: 'https://tc39.github.io/ecma262/#sec-asynciterator-interface', |
335 | 304 | AsyncIterable: 'https://tc39.github.io/ecma262/#sec-asynciterable-interface',
|
336 |
| - AsyncFunction: 'https://tc39.es/ecma262/#sec-async-function-constructor', |
337 | 305 |
|
338 | 306 | 'Module Namespace Object':
|
339 | 307 | 'https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects',
|
340 | 308 |
|
341 |
| - AsyncGeneratorFunction: |
342 |
| - 'https://tc39.es/proposal-async-iteration/#sec-asyncgeneratorfunction-constructor', |
343 |
| - |
344 | 309 | 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 | 310 |
|
347 | 311 | CloseEvent: `${DOC_MDN_BASE_URL}/API/CloseEvent`,
|
348 | 312 | EventSource: `${DOC_MDN_BASE_URL}/API/EventSource`,
|
|
0 commit comments