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 Feb 7, 2025
1 parent ef30314 commit db0fadd
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 @@ -695,8 +695,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 @@ -711,8 +711,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 @@ -843,10 +842,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 @@ -2343,8 +2342,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 @@ -2363,8 +2362,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 @@ -2402,8 +2401,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 @@ -2543,7 +2542,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 @@ -2562,7 +2561,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 @@ -2623,7 +2622,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 @@ -2640,7 +2639,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 @@ -2697,7 +2696,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 @@ -2714,7 +2713,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 @@ -2731,7 +2730,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 @@ -2759,7 +2758,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 @@ -2775,7 +2774,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 @@ -2876,7 +2875,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 @@ -2891,7 +2890,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 @@ -2925,7 +2924,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 @@ -2941,7 +2940,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 @@ -2960,8 +2959,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 @@ -3013,7 +3012,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 @@ -3032,7 +3031,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 @@ -3049,7 +3048,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 @@ -3066,7 +3065,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 @@ -3083,7 +3082,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 @@ -3100,7 +3099,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 @@ -3115,7 +3114,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 @@ -3182,31 +3181,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 db0fadd

Please sign in to comment.