Skip to content

Commit

Permalink
doc: make MDN links to global classes more consistent in util.md
Browse files Browse the repository at this point in the history
PR-URL: #56922
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
aduh95 authored and targos committed Feb 10, 2025
1 parent 5f4377a commit d901987
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 57 deletions.
87 changes: 33 additions & 54 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,8 @@ changes:
* `object` {any} Any JavaScript primitive or `Object`.
* `options` {Object}
* `showHidden` {boolean} If `true`, `object`'s non-enumerable symbols and
properties are included in the formatted result. [`WeakMap`][] and
[`WeakSet`][] entries are also included as well as user defined prototype
properties are included in the formatted result. {WeakMap} and
{WeakSet} entries are also included as well as user defined prototype
properties (excluding method properties). **Default:** `false`.
* `depth` {number} Specifies the number of times to recurse while formatting
`object`. This is useful for inspecting large objects. To recurse up to
Expand All @@ -707,8 +707,7 @@ changes:
* `showProxy` {boolean} If `true`, `Proxy` inspection includes
the [`target` and `handler`][] objects. **Default:** `false`.
* `maxArrayLength` {integer} Specifies the maximum number of `Array`,
[`TypedArray`][], [`Map`][], [`Set`][], [`WeakMap`][],
and [`WeakSet`][] elements to include when formatting.
{TypedArray}, {Map}, {WeakMap}, and {WeakSet} elements to include when formatting.
Set to `null` or `Infinity` to show all elements. Set to `0` or
negative to show no elements. **Default:** `100`.
* `maxStringLength` {integer} Specifies the maximum number of characters to
Expand Down Expand Up @@ -839,10 +838,10 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
// single line.
```

The `showHidden` option allows [`WeakMap`][] and [`WeakSet`][] entries to be
The `showHidden` option allows {WeakMap} and {WeakSet} entries to be
inspected. If there are more entries than `maxArrayLength`, there is no
guarantee which entries are displayed. That means retrieving the same
[`WeakSet`][] entries twice may result in different output. Furthermore, entries
{WeakSet} entries twice may result in different output. Furthermore, entries
with no remaining strong references may be garbage collected at any time.

```js
Expand Down Expand Up @@ -2337,8 +2336,8 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`ArrayBuffer`][] or
[`SharedArrayBuffer`][] instance.
Returns `true` if the value is a built-in {ArrayBuffer} or
{SharedArrayBuffer} instance.
See also [`util.types.isArrayBuffer()`][] and
[`util.types.isSharedArrayBuffer()`][].
Expand All @@ -2357,8 +2356,8 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is an instance of one of the [`ArrayBuffer`][]
views, such as typed array objects or [`DataView`][]. Equivalent to
Returns `true` if the value is an instance of one of the {ArrayBuffer}
views, such as typed array objects or {DataView}. Equivalent to
[`ArrayBuffer.isView()`][].
```js
Expand Down Expand Up @@ -2396,8 +2395,8 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`ArrayBuffer`][] instance.
This does _not_ include [`SharedArrayBuffer`][] instances. Usually, it is
Returns `true` if the value is a built-in {ArrayBuffer} instance.
This does _not_ include {SharedArrayBuffer} instances. Usually, it is
desirable to test for both; See [`util.types.isAnyArrayBuffer()`][] for that.
```js
Expand Down Expand Up @@ -2537,7 +2536,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`DataView`][] instance.
Returns `true` if the value is a built-in {DataView} instance.
```js
const ab = new ArrayBuffer(20);
Expand All @@ -2556,7 +2555,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Date`][] instance.
Returns `true` if the value is a built-in {Date} instance.
```js
util.types.isDate(new Date()); // Returns true
Expand Down Expand Up @@ -2617,7 +2616,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Float32Array`][] instance.
Returns `true` if the value is a built-in {Float32Array} instance.
```js
util.types.isFloat32Array(new ArrayBuffer()); // Returns false
Expand All @@ -2634,7 +2633,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Float64Array`][] instance.
Returns `true` if the value is a built-in {Float64Array} instance.
```js
util.types.isFloat64Array(new ArrayBuffer()); // Returns false
Expand Down Expand Up @@ -2691,7 +2690,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Int8Array`][] instance.
Returns `true` if the value is a built-in {Int8Array} instance.
```js
util.types.isInt8Array(new ArrayBuffer()); // Returns false
Expand All @@ -2708,7 +2707,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Int16Array`][] instance.
Returns `true` if the value is a built-in {Int16Array} instance.
```js
util.types.isInt16Array(new ArrayBuffer()); // Returns false
Expand All @@ -2725,7 +2724,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Int32Array`][] instance.
Returns `true` if the value is a built-in {Int32Array} instance.
```js
util.types.isInt32Array(new ArrayBuffer()); // Returns false
Expand Down Expand Up @@ -2753,7 +2752,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Map`][] instance.
Returns `true` if the value is a built-in {Map} instance.
```js
util.types.isMap(new Map()); // Returns true
Expand All @@ -2769,7 +2768,7 @@ added: v10.0.0
* Returns: {boolean}
Returns `true` if the value is an iterator returned for a built-in
[`Map`][] instance.
{Map} instance.
```js
const map = new Map();
Expand Down Expand Up @@ -2870,7 +2869,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Promise`][].
Returns `true` if the value is a built-in {Promise}.
```js
util.types.isPromise(Promise.resolve(42)); // Returns true
Expand All @@ -2885,7 +2884,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a [`Proxy`][] instance.
Returns `true` if the value is a {Proxy} instance.
```js
const target = {};
Expand Down Expand Up @@ -2919,7 +2918,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Set`][] instance.
Returns `true` if the value is a built-in {Set} instance.
```js
util.types.isSet(new Set()); // Returns true
Expand All @@ -2935,7 +2934,7 @@ added: v10.0.0
* Returns: {boolean}
Returns `true` if the value is an iterator returned for a built-in
[`Set`][] instance.
{Set} instance.
```js
const set = new Set();
Expand All @@ -2954,8 +2953,8 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`SharedArrayBuffer`][] instance.
This does _not_ include [`ArrayBuffer`][] instances. Usually, it is
Returns `true` if the value is a built-in {SharedArrayBuffer} instance.
This does _not_ include {ArrayBuffer} instances. Usually, it is
desirable to test for both; See [`util.types.isAnyArrayBuffer()`][] for that.
```js
Expand Down Expand Up @@ -3007,7 +3006,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`TypedArray`][] instance.
Returns `true` if the value is a built-in {TypedArray} instance.
```js
util.types.isTypedArray(new ArrayBuffer()); // Returns false
Expand All @@ -3026,7 +3025,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Uint8Array`][] instance.
Returns `true` if the value is a built-in {Uint8Array} instance.
```js
util.types.isUint8Array(new ArrayBuffer()); // Returns false
Expand All @@ -3043,7 +3042,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Uint8ClampedArray`][] instance.
Returns `true` if the value is a built-in {Uint8ClampedArray} instance.
```js
util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
Expand All @@ -3060,7 +3059,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Uint16Array`][] instance.
Returns `true` if the value is a built-in {Uint16Array} instance.
```js
util.types.isUint16Array(new ArrayBuffer()); // Returns false
Expand All @@ -3077,7 +3076,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`Uint32Array`][] instance.
Returns `true` if the value is a built-in {Uint32Array} instance.
```js
util.types.isUint32Array(new ArrayBuffer()); // Returns false
Expand All @@ -3094,7 +3093,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`WeakMap`][] instance.
Returns `true` if the value is a built-in {WeakMap} instance.
```js
util.types.isWeakMap(new WeakMap()); // Returns true
Expand All @@ -3109,7 +3108,7 @@ added: v10.0.0
* `value` {any}
* Returns: {boolean}
Returns `true` if the value is a built-in [`WeakSet`][] instance.
Returns `true` if the value is a built-in {WeakSet} instance.
```js
util.types.isWeakSet(new WeakSet()); // Returns true
Expand Down Expand Up @@ -3176,31 +3175,11 @@ util.isArray({});
[`'warning'`]: process.md#event-warning
[`Array.isArray()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
[`ArrayBuffer.isView()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
[`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
[`Date`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
[`Float32Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array
[`Float64Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array
[`Int16Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array
[`Int32Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array
[`Int8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
[`MIMEparams`]: #class-utilmimeparams
[`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
[`Object.assign()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
[`Object.freeze()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
[`Promise`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
[`Proxy`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
[`Runtime.ScriptId`]: https://chromedevtools.github.io/devtools-protocol/1-3/Runtime/#type-ScriptId
[`Set`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
[`SharedArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
[`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
[`Uint16Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array
[`Uint32Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array
[`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
[`Uint8ClampedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray
[`WeakMap`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
[`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
[`assert.deepStrictEqual()`]: assert.md#assertdeepstrictequalactual-expected-message
[`console.error()`]: console.md#consoleerrordata-args
[`mime.toString()`]: #mimetostring
Expand Down
11 changes: 8 additions & 3 deletions tools/doc/type-parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ const jsPrimitives = {
const jsGlobalObjectsUrl = `${jsDocPrefix}Reference/Global_Objects/`;
const jsGlobalTypes = [
'AggregateError', 'Array', 'ArrayBuffer', 'DataView', 'Date', 'Error',
'EvalError', 'Function', 'Map', 'Object', 'Promise', 'Proxy', 'RangeError',
'ReferenceError', 'RegExp', 'Set', 'SharedArrayBuffer', 'SyntaxError',
'TypeError', 'TypedArray', 'URIError', 'Uint8Array',
'EvalError', 'Function', 'Map', 'NaN', 'Object', 'Promise', 'Proxy', 'RangeError',
'ReferenceError', 'RegExp', 'Set', 'SharedArrayBuffer', 'SyntaxError', 'Symbol',
'TypeError', 'URIError', 'WeakMap', 'WeakSet',

'TypedArray',
'Float32Array', 'Float64Array',
'Int8Array', 'Int16Array', 'Int32Array',
'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array',
];

const customTypesMap = {
Expand Down

0 comments on commit d901987

Please # to comment.