Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2d780f8

Browse files
vsemozhetbytBethGriggs
authored andcommittedApr 9, 2019
doc: unify link formatting in buffer.md
PR-URL: #27030 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent 6e3b6c5 commit 2d780f8

File tree

1 file changed

+118
-116
lines changed

1 file changed

+118
-116
lines changed
 

‎doc/api/buffer.md

+118-116
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
> Stability: 2 - Stable
66
7-
Prior to the introduction of [`TypedArray`], the JavaScript language had no
7+
Prior to the introduction of [`TypedArray`][], the JavaScript language had no
88
mechanism for reading or manipulating streams of binary data. The `Buffer` class
99
was introduced as part of the Node.js API to enable interaction with octet
1010
streams in TCP streams, file system operations, and other contexts.
1111

12-
With [`TypedArray`] now available, the `Buffer` class implements the
13-
[`Uint8Array`] API in a manner that is more optimized and suitable for Node.js.
12+
With [`TypedArray`][] now available, the `Buffer` class implements the
13+
[`Uint8Array`][] API in a manner that is more optimized and suitable for
14+
Node.js.
1415

1516
Instances of the `Buffer` class are similar to arrays of integers from `0` to
1617
`255` (other integers are coerced to this range by `& 255` operation) but
@@ -62,8 +63,8 @@ differently based on what arguments are provided:
6263
`new Buffer(num)` will return a `Buffer` with initialized memory.
6364
* Passing a string, array, or `Buffer` as the first argument copies the
6465
passed object's data into the `Buffer`.
65-
* Passing an [`ArrayBuffer`] or a [`SharedArrayBuffer`] returns a `Buffer` that
66-
shares allocated memory with the given array buffer.
66+
* Passing an [`ArrayBuffer`][] or a [`SharedArrayBuffer`][] returns a `Buffer`
67+
that shares allocated memory with the given array buffer.
6768

6869
Because the behavior of `new Buffer()` is different depending on the type of the
6970
first argument, security and reliability issues can be inadvertently introduced
@@ -72,18 +73,18 @@ performed.
7273

7374
To make the creation of `Buffer` instances more reliable and less error-prone,
7475
the various forms of the `new Buffer()` constructor have been **deprecated**
75-
and replaced by separate `Buffer.from()`, [`Buffer.alloc()`], and
76-
[`Buffer.allocUnsafe()`] methods.
76+
and replaced by separate `Buffer.from()`, [`Buffer.alloc()`][], and
77+
[`Buffer.allocUnsafe()`][] methods.
7778

7879
*Developers should migrate all existing uses of the `new Buffer()` constructors
7980
to one of these new APIs.*
8081

81-
* [`Buffer.from(array)`] returns a new `Buffer` that *contains a copy* of the
82+
* [`Buffer.from(array)`][] returns a new `Buffer` that *contains a copy* of the
8283
provided octets.
8384
* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
8485
returns a new `Buffer` that *shares the same allocated memory* as the given
85-
[`ArrayBuffer`].
86-
* [`Buffer.from(buffer)`] returns a new `Buffer` that *contains a copy* of the
86+
[`ArrayBuffer`][].
87+
* [`Buffer.from(buffer)`][] returns a new `Buffer` that *contains a copy* of the
8788
contents of the given `Buffer`.
8889
* [`Buffer.from(string[, encoding])`][`Buffer.from(string)`] returns a new
8990
`Buffer` that *contains a copy* of the provided string.
@@ -98,10 +99,10 @@ to one of these new APIs.*
9899
uninitialized, the allocated segment of memory might contain old data that is
99100
potentially sensitive.
100101

101-
`Buffer` instances returned by [`Buffer.allocUnsafe()`] *may* be allocated off
102+
`Buffer` instances returned by [`Buffer.allocUnsafe()`][] *may* be allocated off
102103
a shared internal memory pool if `size` is less than or equal to half
103-
[`Buffer.poolSize`]. Instances returned by [`Buffer.allocUnsafeSlow()`] *never*
104-
use the shared internal memory pool.
104+
[`Buffer.poolSize`][]. Instances returned by [`Buffer.allocUnsafeSlow()`][]
105+
*never* use the shared internal memory pool.
105106

106107
### The `--zero-fill-buffers` command line option
107108
<!-- YAML
@@ -111,7 +112,7 @@ added: v5.10.0
111112
Node.js can be started using the `--zero-fill-buffers` command line option to
112113
cause all newly allocated `Buffer` instances to be zero-filled upon creation by
113114
default, including buffers returned by `new Buffer(size)`,
114-
[`Buffer.allocUnsafe()`], [`Buffer.allocUnsafeSlow()`], and `new
115+
[`Buffer.allocUnsafe()`][], [`Buffer.allocUnsafeSlow()`][], and `new
115116
SlowBuffer(size)`. Use of this flag can have a significant negative impact on
116117
performance. Use of the `--zero-fill-buffers` option is recommended only when
117118
necessary to enforce that newly allocated `Buffer` instances cannot contain old
@@ -125,16 +126,16 @@ $ node --zero-fill-buffers
125126

126127
### What makes `Buffer.allocUnsafe()` and `Buffer.allocUnsafeSlow()` "unsafe"?
127128

128-
When calling [`Buffer.allocUnsafe()`] and [`Buffer.allocUnsafeSlow()`], the
129+
When calling [`Buffer.allocUnsafe()`][] and [`Buffer.allocUnsafeSlow()`][], the
129130
segment of allocated memory is *uninitialized* (it is not zeroed-out). While
130131
this design makes the allocation of memory quite fast, the allocated segment of
131132
memory might contain old data that is potentially sensitive. Using a `Buffer`
132-
created by [`Buffer.allocUnsafe()`] without *completely* overwriting the memory
133-
can allow this old data to be leaked when the `Buffer` memory is read.
133+
created by [`Buffer.allocUnsafe()`][] without *completely* overwriting the
134+
memory can allow this old data to be leaked when the `Buffer` memory is read.
134135

135-
While there are clear performance advantages to using [`Buffer.allocUnsafe()`],
136-
extra care *must* be taken in order to avoid introducing security
137-
vulnerabilities into an application.
136+
While there are clear performance advantages to using
137+
[`Buffer.allocUnsafe()`][], extra care *must* be taken in order to avoid
138+
introducing security vulnerabilities into an application.
138139

139140
## Buffers and Character Encodings
140141
<!-- YAML
@@ -179,10 +180,10 @@ The character encodings currently supported by Node.js include:
179180

180181
* `'base64'` - Base64 encoding. When creating a `Buffer` from a string,
181182
this encoding will also correctly accept "URL and Filename Safe Alphabet" as
182-
specified in [RFC 4648, Section 5].
183+
specified in [RFC 4648, Section 5][].
183184

184185
* `'latin1'` - A way of encoding the `Buffer` into a one-byte encoded string
185-
(as defined by the IANA in [RFC 1345],
186+
(as defined by the IANA in [RFC 1345][],
186187
page 63, to be the Latin-1 supplement block and C0/C1 control codes).
187188

188189
* `'binary'` - Alias for `'latin1'`.
@@ -204,25 +205,26 @@ changes:
204205
description: The `Buffer`s class now inherits from `Uint8Array`.
205206
-->
206207

207-
`Buffer` instances are also [`Uint8Array`] instances. However, there are subtle
208-
incompatibilities with [`TypedArray`]. For example, while
209-
[`ArrayBuffer#slice()`] creates a copy of the slice, the implementation of
208+
`Buffer` instances are also [`Uint8Array`][] instances. However, there are
209+
subtle incompatibilities with [`TypedArray`][]. For example, while
210+
[`ArrayBuffer#slice()`][] creates a copy of the slice, the implementation of
210211
[`Buffer#slice()`][`buf.slice()`] creates a view over the existing `Buffer`
211212
without copying, making [`Buffer#slice()`][`buf.slice()`] far more efficient.
212213

213-
It is also possible to create new [`TypedArray`] instances from a `Buffer` with
214-
the following caveats:
214+
It is also possible to create new [`TypedArray`][] instances from a `Buffer`
215+
with the following caveats:
215216

216-
1. The `Buffer` object's memory is copied to the [`TypedArray`], not shared.
217+
1. The `Buffer` object's memory is copied to the [`TypedArray`][], not shared.
217218

218219
2. The `Buffer` object's memory is interpreted as an array of distinct
219220
elements, and not as a byte array of the target type. That is,
220-
`new Uint32Array(Buffer.from([1, 2, 3, 4]))` creates a 4-element [`Uint32Array`]
221-
with elements `[1, 2, 3, 4]`, not a [`Uint32Array`] with a single element
222-
`[0x1020304]` or `[0x4030201]`.
221+
`new Uint32Array(Buffer.from([1, 2, 3, 4]))` creates a 4-element
222+
[`Uint32Array`][] with elements `[1, 2, 3, 4]`, not a [`Uint32Array`][] with a
223+
single element `[0x1020304]` or `[0x4030201]`.
223224

224225
It is possible to create a new `Buffer` that shares the same allocated memory as
225-
a [`TypedArray`] instance by using the `TypedArray` object's `.buffer` property.
226+
a [`TypedArray`][] instance by using the `TypedArray` object's `.buffer`
227+
property.
226228

227229
```js
228230
const arr = new Uint16Array(2);
@@ -248,8 +250,8 @@ console.log(buf2);
248250
// Prints: <Buffer 88 13 70 17>
249251
```
250252

251-
Note that when creating a `Buffer` using a [`TypedArray`]'s `.buffer`, it is
252-
possible to use only a portion of the underlying [`ArrayBuffer`] by passing in
253+
Note that when creating a `Buffer` using a [`TypedArray`][]'s `.buffer`, it is
254+
possible to use only a portion of the underlying [`ArrayBuffer`][] by passing in
253255
`byteOffset` and `length` parameters.
254256

255257
```js
@@ -260,8 +262,8 @@ console.log(buf.length);
260262
// Prints: 16
261263
```
262264

263-
The `Buffer.from()` and [`TypedArray.from()`] have different signatures and
264-
implementations. Specifically, the [`TypedArray`] variants accept a second
265+
The `Buffer.from()` and [`TypedArray.from()`][] have different signatures and
266+
implementations. Specifically, the [`TypedArray`][] variants accept a second
265267
argument that is a mapping function that is invoked on every element of the
266268
typed array:
267269

@@ -270,8 +272,8 @@ typed array:
270272
The `Buffer.from()` method, however, does not support the use of a mapping
271273
function:
272274

273-
* [`Buffer.from(array)`]
274-
* [`Buffer.from(buffer)`]
275+
* [`Buffer.from(array)`][]
276+
* [`Buffer.from(buffer)`][]
275277
* [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
276278
* [`Buffer.from(string[, encoding])`][`Buffer.from(string)`]
277279

@@ -291,8 +293,8 @@ for (const b of buf) {
291293
// 3
292294
```
293295

294-
Additionally, the [`buf.values()`], [`buf.keys()`], and
295-
[`buf.entries()`] methods can be used to create iterators.
296+
Additionally, the [`buf.values()`][], [`buf.keys()`][], and
297+
[`buf.entries()`][] methods can be used to create iterators.
296298

297299
## Class: Buffer
298300

@@ -315,7 +317,7 @@ changes:
315317
description: Calling this constructor emits a deprecation warning now.
316318
-->
317319

318-
> Stability: 0 - Deprecated: Use [`Buffer.from(array)`] instead.
320+
> Stability: 0 - Deprecated: Use [`Buffer.from(array)`][] instead.
319321
320322
* `array` {integer[]} An array of bytes to copy from.
321323

@@ -350,16 +352,16 @@ changes:
350352
> [`Buffer.from(arrayBuffer[, byteOffset[, length]])`][`Buffer.from(arrayBuf)`]
351353
> instead.
352354
353-
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
354-
[`SharedArrayBuffer`] or the `.buffer` property of a [`TypedArray`].
355+
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`][],
356+
[`SharedArrayBuffer`][] or the `.buffer` property of a [`TypedArray`][].
355357
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
356358
* `length` {integer} Number of bytes to expose.
357359
**Default:** `arrayBuffer.length - byteOffset`.
358360

359-
This creates a view of the [`ArrayBuffer`] or [`SharedArrayBuffer`] without
361+
This creates a view of the [`ArrayBuffer`][] or [`SharedArrayBuffer`][] without
360362
copying the underlying memory. For example, when passed a reference to the
361-
`.buffer` property of a [`TypedArray`] instance, the newly created `Buffer` will
362-
share the same allocated memory as the [`TypedArray`].
363+
`.buffer` property of a [`TypedArray`][] instance, the newly created `Buffer`
364+
will share the same allocated memory as the [`TypedArray`][].
363365

364366
The optional `byteOffset` and `length` arguments specify a memory range within
365367
the `arrayBuffer` that will be shared by the `Buffer`.
@@ -399,10 +401,10 @@ changes:
399401
description: Calling this constructor emits a deprecation warning now.
400402
-->
401403

402-
> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`] instead.
404+
> Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`][] instead.
403405
404-
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which
405-
to copy data.
406+
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`][] from
407+
which to copy data.
406408

407409
Copies the passed `buffer` data onto a new `Buffer` instance.
408410

@@ -438,14 +440,14 @@ changes:
438440
description: Calling this constructor emits a deprecation warning now.
439441
-->
440442

441-
> Stability: 0 - Deprecated: Use [`Buffer.alloc()`] instead (also see
442-
> [`Buffer.allocUnsafe()`]).
443+
> Stability: 0 - Deprecated: Use [`Buffer.alloc()`][] instead (also see
444+
> [`Buffer.allocUnsafe()`][]).
443445
444446
* `size` {integer} The desired length of the new `Buffer`.
445447

446448
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
447-
[`buffer.constants.MAX_LENGTH`] or smaller than 0, [`ERR_INVALID_OPT_VALUE`] is
448-
thrown. A zero-length `Buffer` is created if `size` is 0.
449+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][]
450+
is thrown. A zero-length `Buffer` is created if `size` is 0.
449451

450452
Prior to Node.js 8.0.0, the underlying memory for `Buffer` instances
451453
created in this way is *not initialized*. The contents of a newly created
@@ -532,8 +534,8 @@ console.log(buf);
532534
```
533535

534536
If `size` is larger than
535-
[`buffer.constants.MAX_LENGTH`] or smaller than 0, [`ERR_INVALID_OPT_VALUE`] is
536-
thrown. A zero-length `Buffer` is created if `size` is 0.
537+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][]
538+
is thrown. A zero-length `Buffer` is created if `size` is 0.
537539

538540
If `fill` is specified, the allocated `Buffer` will be initialized by calling
539541
[`buf.fill(fill)`][`buf.fill()`].
@@ -555,8 +557,8 @@ console.log(buf);
555557
// Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
556558
```
557559

558-
Calling [`Buffer.alloc()`] can be significantly slower than the alternative
559-
[`Buffer.allocUnsafe()`] but ensures that the newly created `Buffer` instance
560+
Calling [`Buffer.alloc()`][] can be significantly slower than the alternative
561+
[`Buffer.allocUnsafe()`][] but ensures that the newly created `Buffer` instance
560562
contents will *never contain sensitive data*.
561563

562564
A `TypeError` will be thrown if `size` is not a number.
@@ -573,12 +575,12 @@ changes:
573575
* `size` {integer} The desired length of the new `Buffer`.
574576

575577
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
576-
[`buffer.constants.MAX_LENGTH`] or smaller than 0, [`ERR_INVALID_OPT_VALUE`] is
577-
thrown. A zero-length `Buffer` is created if `size` is 0.
578+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][]
579+
is thrown. A zero-length `Buffer` is created if `size` is 0.
578580

579581
The underlying memory for `Buffer` instances created in this way is *not
580582
initialized*. The contents of the newly created `Buffer` are unknown and
581-
*may contain sensitive data*. Use [`Buffer.alloc()`] instead to initialize
583+
*may contain sensitive data*. Use [`Buffer.alloc()`][] instead to initialize
582584
`Buffer` instances with zeroes.
583585

584586
```js
@@ -596,18 +598,18 @@ console.log(buf);
596598
A `TypeError` will be thrown if `size` is not a number.
597599

598600
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
599-
size [`Buffer.poolSize`] that is used as a pool for the fast allocation of new
600-
`Buffer` instances created using [`Buffer.allocUnsafe()`] and the deprecated
601+
size [`Buffer.poolSize`][] that is used as a pool for the fast allocation of new
602+
`Buffer` instances created using [`Buffer.allocUnsafe()`][] and the deprecated
601603
`new Buffer(size)` constructor only when `size` is less than or equal to
602-
`Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`] divided by two).
604+
`Buffer.poolSize >> 1` (floor of [`Buffer.poolSize`][] divided by two).
603605

604606
Use of this pre-allocated internal memory pool is a key difference between
605607
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
606608
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal `Buffer`
607609
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
608-
`Buffer` pool if `size` is less than or equal to half [`Buffer.poolSize`]. The
610+
`Buffer` pool if `size` is less than or equal to half [`Buffer.poolSize`][]. The
609611
difference is subtle but can be important when an application requires the
610-
additional performance that [`Buffer.allocUnsafe()`] provides.
612+
additional performance that [`Buffer.allocUnsafe()`][] provides.
611613

612614
### Class Method: Buffer.allocUnsafeSlow(size)
613615
<!-- YAML
@@ -617,15 +619,15 @@ added: v5.12.0
617619
* `size` {integer} The desired length of the new `Buffer`.
618620

619621
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
620-
[`buffer.constants.MAX_LENGTH`] or smaller than 0, [`ERR_INVALID_OPT_VALUE`] is
621-
thrown. A zero-length `Buffer` is created if `size` is 0.
622+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][]
623+
is thrown. A zero-length `Buffer` is created if `size` is 0.
622624

623625
The underlying memory for `Buffer` instances created in this way is *not
624626
initialized*. The contents of the newly created `Buffer` are unknown and
625627
*may contain sensitive data*. Use [`buf.fill(0)`][`buf.fill()`] to initialize
626628
such `Buffer` instances with zeroes.
627629

628-
When using [`Buffer.allocUnsafe()`] to allocate new `Buffer` instances,
630+
When using [`Buffer.allocUnsafe()`][] to allocate new `Buffer` instances,
629631
allocations under 4KB are sliced from a single pre-allocated `Buffer`. This
630632
allows applications to avoid the garbage collection overhead of creating many
631633
individually allocated `Buffer` instances. This approach improves both
@@ -680,7 +682,7 @@ changes:
680682
* Returns: {integer} The number of bytes contained within `string`.
681683

682684
Returns the actual byte length of a string. This is not the same as
683-
[`String.prototype.length`] since that returns the number of *characters* in
685+
[`String.prototype.length`][] since that returns the number of *characters* in
684686
a string.
685687

686688
For `'base64'` and `'hex'`, this function assumes valid input. For strings that
@@ -695,8 +697,8 @@ console.log(`${str}: ${str.length} characters, ` +
695697
// Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
696698
```
697699

698-
When `string` is a `Buffer`/[`DataView`]/[`TypedArray`]/[`ArrayBuffer`]/
699-
[`SharedArrayBuffer`], the actual byte length is returned.
700+
When `string` is a `Buffer`/[`DataView`][]/[`TypedArray`][]/[`ArrayBuffer`][]/
701+
[`SharedArrayBuffer`][], the actual byte length is returned.
700702

701703
### Class Method: Buffer.compare(buf1, buf2)
702704
<!-- YAML
@@ -734,8 +736,8 @@ changes:
734736
description: The elements of `list` can now be `Uint8Array`s.
735737
-->
736738

737-
* `list` {Buffer[] | Uint8Array[]} List of `Buffer` or [`Uint8Array`] instances
738-
to concat.
739+
* `list` {Buffer[] | Uint8Array[]} List of `Buffer` or [`Uint8Array`][]
740+
instances to concat.
739741
* `totalLength` {integer} Total length of the `Buffer` instances in `list`
740742
when concatenated.
741743
* Returns: {Buffer}
@@ -796,16 +798,16 @@ appropriate for `Buffer.from()` variants.
796798
added: v5.10.0
797799
-->
798800

799-
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`],
800-
[`SharedArrayBuffer`], or the `.buffer` property of a [`TypedArray`].
801+
* `arrayBuffer` {ArrayBuffer|SharedArrayBuffer} An [`ArrayBuffer`][],
802+
[`SharedArrayBuffer`][], or the `.buffer` property of a [`TypedArray`][].
801803
* `byteOffset` {integer} Index of first byte to expose. **Default:** `0`.
802804
* `length` {integer} Number of bytes to expose.
803805
**Default:** `arrayBuffer.length - byteOffset`.
804806

805-
This creates a view of the [`ArrayBuffer`] without copying the underlying
807+
This creates a view of the [`ArrayBuffer`][] without copying the underlying
806808
memory. For example, when passed a reference to the `.buffer` property of a
807-
[`TypedArray`] instance, the newly created `Buffer` will share the same
808-
allocated memory as the [`TypedArray`].
809+
[`TypedArray`][] instance, the newly created `Buffer` will share the same
810+
allocated memory as the [`TypedArray`][].
809811

810812
```js
811813
const arr = new Uint16Array(2);
@@ -837,16 +839,16 @@ console.log(buf.length);
837839
// Prints: 2
838840
```
839841

840-
A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a
841-
[`SharedArrayBuffer`] or other type appropriate for `Buffer.from()` variants.
842+
A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`][] or a
843+
[`SharedArrayBuffer`][] or other type appropriate for `Buffer.from()` variants.
842844

843845
### Class Method: Buffer.from(buffer)
844846
<!-- YAML
845847
added: v5.10.0
846848
-->
847849

848-
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which
849-
to copy data.
850+
* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`][] from
851+
which to copy data.
850852

851853
Copies the passed `buffer` data onto a new `Buffer` instance.
852854

@@ -1039,7 +1041,7 @@ changes:
10391041
description: Additional parameters for specifying offsets are supported now.
10401042
-->
10411043

1042-
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] with which to
1044+
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`][] with which to
10431045
compare `buf`.
10441046
* `targetStart` {integer} The offset within `target` at which to begin
10451047
comparison. **Default:** `0`.
@@ -1048,7 +1050,7 @@ changes:
10481050
* `sourceStart` {integer} The offset within `buf` at which to begin comparison.
10491051
**Default:** `0`.
10501052
* `sourceEnd` {integer} The offset within `buf` at which to end comparison
1051-
(not inclusive). **Default:** [`buf.length`].
1053+
(not inclusive). **Default:** [`buf.length`][].
10521054
* Returns: {integer}
10531055

10541056
Compares `buf` with `target` and returns a number indicating whether `buf`
@@ -1095,21 +1097,21 @@ console.log(buf1.compare(buf2, 5, 6, 5));
10951097
// Prints: 1
10961098
```
10971099

1098-
[`ERR_OUT_OF_RANGE`] is thrown if `targetStart < 0`, `sourceStart < 0`,
1100+
[`ERR_OUT_OF_RANGE`][] is thrown if `targetStart < 0`, `sourceStart < 0`,
10991101
`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
11001102

11011103
### buf.copy(target[, targetStart[, sourceStart[, sourceEnd]]])
11021104
<!-- YAML
11031105
added: v0.1.90
11041106
-->
11051107

1106-
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] to copy into.
1108+
* `target` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`][] to copy into.
11071109
* `targetStart` {integer} The offset within `target` at which to begin
11081110
writing. **Default:** `0`.
11091111
* `sourceStart` {integer} The offset within `buf` from which to begin copying.
11101112
**Default:** `0`.
11111113
* `sourceEnd` {integer} The offset within `buf` at which to stop copying (not
1112-
inclusive). **Default:** [`buf.length`].
1114+
inclusive). **Default:** [`buf.length`][].
11131115
* Returns: {integer} The number of bytes copied.
11141116

11151117
Copies data from a region of `buf` to a region in `target` even if the `target`
@@ -1156,8 +1158,8 @@ added: v1.1.0
11561158

11571159
* Returns: {Iterator}
11581160

1159-
Creates and returns an [iterator] of `[index, byte]` pairs from the contents of
1160-
`buf`.
1161+
Creates and returns an [iterator][] of `[index, byte]` pairs from the contents
1162+
of `buf`.
11611163

11621164
```js
11631165
// Log the entire contents of a `Buffer`.
@@ -1185,7 +1187,7 @@ changes:
11851187
description: The arguments can now be `Uint8Array`s.
11861188
-->
11871189

1188-
* `otherBuffer` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`] with which to
1190+
* `otherBuffer` {Buffer|Uint8Array} A `Buffer` or [`Uint8Array`][] with which to
11891191
compare `buf`.
11901192
* Returns: {boolean}
11911193

@@ -1230,7 +1232,7 @@ changes:
12301232
* `offset` {integer} Number of bytes to skip before starting to fill `buf`.
12311233
**Default:** `0`.
12321234
* `end` {integer} Where to stop filling `buf` (not inclusive). **Default:**
1233-
[`buf.length`].
1235+
[`buf.length`][].
12341236
* `encoding` {string} The encoding for `value` if `value` is a string.
12351237
**Default:** `'utf8'`.
12361238
* Returns: {Buffer} A reference to `buf`.
@@ -1334,8 +1336,8 @@ If `value` is:
13341336

13351337
* a string, `value` is interpreted according to the character encoding in
13361338
`encoding`.
1337-
* a `Buffer` or [`Uint8Array`], `value` will be used in its entirety.
1338-
To compare a partial `Buffer`, use [`buf.slice()`].
1339+
* a `Buffer` or [`Uint8Array`][], `value` will be used in its entirety.
1340+
To compare a partial `Buffer`, use [`buf.slice()`][].
13391341
* a number, `value` will be interpreted as an unsigned 8-bit integer
13401342
value between `0` and `255`.
13411343

@@ -1369,7 +1371,7 @@ an integer between 0 and 255.
13691371

13701372
If `byteOffset` is not a number, it will be coerced to a number. If the result
13711373
of coercion is `NaN` or `0`, then the entire buffer will be searched. This
1372-
behavior matches [`String#indexOf()`].
1374+
behavior matches [`String#indexOf()`][].
13731375

13741376
```js
13751377
const b = Buffer.from('abcdef');
@@ -1398,7 +1400,7 @@ added: v1.1.0
13981400

13991401
* Returns: {Iterator}
14001402

1401-
Creates and returns an [iterator] of `buf` keys (indices).
1403+
Creates and returns an [iterator][] of `buf` keys (indices).
14021404

14031405
```js
14041406
const buf = Buffer.from('buffer');
@@ -1427,14 +1429,14 @@ changes:
14271429
* `value` {string|Buffer|Uint8Array|integer} What to search for.
14281430
* `byteOffset` {integer} Where to begin searching in `buf`. If negative, then
14291431
offset is calculated from the end of `buf`. **Default:**
1430-
[`buf.length`]` - 1`.
1432+
[`buf.length`][]` - 1`.
14311433
* `encoding` {string} If `value` is a string, this is the encoding used to
14321434
determine the binary representation of the string that will be searched for in
14331435
`buf`. **Default:** `'utf8'`.
14341436
* Returns: {integer} The index of the last occurrence of `value` in `buf`, or
14351437
`-1` if `buf` does not contain `value`.
14361438

1437-
Identical to [`buf.indexOf()`], except the last occurrence of `value` is found
1439+
Identical to [`buf.indexOf()`][], except the last occurrence of `value` is found
14381440
rather than the first occurrence.
14391441

14401442
```js
@@ -1469,7 +1471,7 @@ an integer between 0 and 255.
14691471

14701472
If `byteOffset` is not a number, it will be coerced to a number. Any arguments
14711473
that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
1472-
This behavior matches [`String#lastIndexOf()`].
1474+
This behavior matches [`String#lastIndexOf()`][].
14731475

14741476
```js
14751477
const b = Buffer.from('abcdef');
@@ -1519,7 +1521,7 @@ console.log(buf.length);
15191521
While the `length` property is not immutable, changing the value of `length`
15201522
can result in undefined and inconsistent behavior. Applications that wish to
15211523
modify the length of a `Buffer` should therefore treat `length` as read-only and
1522-
use [`buf.slice()`] to create a new `Buffer`.
1524+
use [`buf.slice()`][] to create a new `Buffer`.
15231525

15241526
```js
15251527
let buf = Buffer.allocUnsafe(10);
@@ -1540,7 +1542,7 @@ console.log(buf.length);
15401542
deprecated: v8.0.0
15411543
-->
15421544

1543-
> Stability: 0 - Deprecated: Use [`buf.buffer`] instead.
1545+
> Stability: 0 - Deprecated: Use [`buf.buffer`][] instead.
15441546
15451547
The `buf.parent` property is a deprecated alias for `buf.buffer`.
15461548

@@ -1870,14 +1872,14 @@ changes:
18701872

18711873
* `start` {integer} Where the new `Buffer` will start. **Default:** `0`.
18721874
* `end` {integer} Where the new `Buffer` will end (not inclusive).
1873-
**Default:** [`buf.length`].
1875+
**Default:** [`buf.length`][].
18741876
* Returns: {Buffer}
18751877

18761878
Returns a new `Buffer` that references the same memory as the original, but
18771879
offset and cropped by the `start` and `end` indices.
18781880

1879-
Specifying `end` greater than [`buf.length`] will return the same result as
1880-
that of `end` equal to [`buf.length`].
1881+
Specifying `end` greater than [`buf.length`][] will return the same result as
1882+
that of `end` equal to [`buf.length`][].
18811883

18821884
Modifying the new `Buffer` slice will modify the memory in the original `Buffer`
18831885
because the allocated memory of the two objects overlap.
@@ -1931,8 +1933,8 @@ added: v5.10.0
19311933
* Returns: {Buffer} A reference to `buf`.
19321934

19331935
Interprets `buf` as an array of unsigned 16-bit integers and swaps the
1934-
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
1935-
not a multiple of 2.
1936+
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`][] if [`buf.length`][]
1937+
is not a multiple of 2.
19361938

19371939
```js
19381940
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
@@ -1967,8 +1969,8 @@ added: v5.10.0
19671969
* Returns: {Buffer} A reference to `buf`.
19681970

19691971
Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1970-
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is
1971-
not a multiple of 4.
1972+
byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`][] if [`buf.length`][]
1973+
is not a multiple of 4.
19721974

19731975
```js
19741976
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
@@ -1995,7 +1997,7 @@ added: v6.3.0
19951997
* Returns: {Buffer} A reference to `buf`.
19961998

19971999
Interprets `buf` as an array of 64-bit numbers and swaps byte order *in-place*.
1998-
Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a multiple of 8.
2000+
Throws [`ERR_INVALID_BUFFER_SIZE`][] if [`buf.length`][] is not a multiple of 8.
19992001

20002002
```js
20012003
const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
@@ -2024,7 +2026,7 @@ added: v0.9.2
20242026

20252027
* Returns: {Object}
20262028

2027-
Returns a JSON representation of `buf`. [`JSON.stringify()`] implicitly calls
2029+
Returns a JSON representation of `buf`. [`JSON.stringify()`][] implicitly calls
20282030
this function when stringifying a `Buffer` instance.
20292031

20302032
```js
@@ -2052,7 +2054,7 @@ added: v0.1.90
20522054
* `encoding` {string} The character encoding to use. **Default:** `'utf8'`.
20532055
* `start` {integer} The byte offset to start decoding at. **Default:** `0`.
20542056
* `end` {integer} The byte offset to stop decoding at (not inclusive).
2055-
**Default:** [`buf.length`].
2057+
**Default:** [`buf.length`][].
20562058
* Returns: {string}
20572059

20582060
Decodes `buf` to a string according to the specified character encoding in
@@ -2091,7 +2093,7 @@ added: v1.1.0
20912093

20922094
* Returns: {Iterator}
20932095

2094-
Creates and returns an [iterator] for `buf` values (bytes). This function is
2096+
Creates and returns an [iterator][] for `buf` values (bytes). This function is
20952097
called automatically when a `Buffer` is used in a `for..of` statement.
20962098

20972099
```js
@@ -2498,7 +2500,7 @@ added: v0.5.4
24982500

24992501
Returns the maximum number of bytes that will be returned when
25002502
`buf.inspect()` is called. This can be overridden by user modules. See
2501-
[`util.inspect()`] for more details on `buf.inspect()` behavior.
2503+
[`util.inspect()`][] for more details on `buf.inspect()` behavior.
25022504

25032505
Note that this is a property on the `buffer` module returned by
25042506
`require('buffer')`, not on the `Buffer` global or a `Buffer` instance.
@@ -2560,7 +2562,7 @@ Note that this is a property on the `buffer` module returned by
25602562
deprecated: v6.0.0
25612563
-->
25622564

2563-
> Stability: 0 - Deprecated: Use [`Buffer.allocUnsafeSlow()`] instead.
2565+
> Stability: 0 - Deprecated: Use [`Buffer.allocUnsafeSlow()`][] instead.
25642566
25652567
Returns an un-pooled `Buffer`.
25662568

@@ -2598,13 +2600,13 @@ has observed undue memory retention in their applications.
25982600
deprecated: v6.0.0
25992601
-->
26002602

2601-
> Stability: 0 - Deprecated: Use [`Buffer.allocUnsafeSlow()`] instead.
2603+
> Stability: 0 - Deprecated: Use [`Buffer.allocUnsafeSlow()`][] instead.
26022604
26032605
* `size` {integer} The desired length of the new `SlowBuffer`.
26042606

26052607
Allocates a new `Buffer` of `size` bytes. If `size` is larger than
2606-
[`buffer.constants.MAX_LENGTH`] or smaller than 0, [`ERR_INVALID_OPT_VALUE`] is
2607-
thrown. A zero-length `Buffer` is created if `size` is 0.
2608+
[`buffer.constants.MAX_LENGTH`][] or smaller than 0, [`ERR_INVALID_OPT_VALUE`][]
2609+
is thrown. A zero-length `Buffer` is created if `size` is 0.
26082610

26092611
The underlying memory for `SlowBuffer` instances is *not initialized*. The
26102612
contents of a newly created `SlowBuffer` are unknown and may contain sensitive

0 commit comments

Comments
 (0)
Please sign in to comment.