Skip to content

Commit

Permalink
doc: improve styling consistency in Buffer docs
Browse files Browse the repository at this point in the history
Add links style consistency.

PR-URL: #5001
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Klauke <romaaan.git@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
estliberitas authored and Myles Borins committed Mar 2, 2016
1 parent aeac623 commit 08d7ac4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions doc/api/buffer.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ console.log(buf2);
Note that when creating a Buffer using the TypeArray's `.buffer`, it is not
currently possible to use only a portion of the underlying `ArrayBuffer`. To
create a Buffer that uses only a part of the `ArrayBuffer`, use the
`buf.slice()` function after the Buffer is created:
[`buf.slice()`][] function after the Buffer is created:

```js
const arr = new Uint16Array(20);
Expand All @@ -140,8 +140,8 @@ for (var b of buf)
// 3
```

Additionally, the `buffer.values()`, `buffer.keys()`, and `buffer.entries()`
methods can be used to create iterators.
Additionally, the [`buf.values()`][], [`buf.keys()`][], and
[`buf.entries()`][] methods can be used to create iterators.

## Class: Buffer

Expand Down Expand Up @@ -276,7 +276,7 @@ console.log(`${str}: ${str.length} characters, ` +
* Return: {Number}

Compares `buf1` to `buf2` typically for the purpose of sorting arrays of
Buffers. This is equivalent is calling `buf1.compare(buf2)`.
Buffers. This is equivalent is calling [`buf1.compare(buf2)`][].

```js
const arr = [Buffer('1234'), Buffer('0123')];
Expand Down Expand Up @@ -499,7 +499,7 @@ Operates similar to [`Array#indexOf()`][] in that it returns either the
starting index position of `value` in Buffer or `-1` if the Buffer does not
contain `value`. The `value` can be a String, Buffer or Number. Strings are by
default interpreted as UTF8. Buffers will use the entire Buffer (to compare a
partial Buffer use [`Buffer#slice()`][]). Numbers can range from 0 to 255.
partial Buffer use [`buf.slice()`][]). Numbers can range from 0 to 255.

```js
const buf = new Buffer('this is a buffer');
Expand Down Expand Up @@ -532,9 +532,10 @@ utf16Buffer.indexOf('\u03a3', -4, 'ucs2');
* `encoding` {String} Default: `'utf8'`
* Return: {Boolean}

Operates similar to [Array#includes()][]. The `value` can be a String, Buffer
Operates similar to [`Array#includes()`][]. The `value` can be a String, Buffer
or Number. Strings are interpreted as UTF8 unless overridden with the
`encoding` argument. Buffers will use the entire Buffer (to compare a partial Buffer use `Buffer#slice()`). Numbers can range from 0 to 255.
`encoding` argument. Buffers will use the entire Buffer (to compare a partial
Buffer use [`buf.slice()`][]). Numbers can range from 0 to 255.

The `byteOffset` indicates the index in `buf` where searching begins.

Expand Down Expand Up @@ -600,7 +601,7 @@ console.log(buf.length);
While the `length` property is not immutable, changing the value of `length`
can result in undefined and inconsistent behavior. Applications that wish to
modify the length of a Buffer should therefore treat `length` as read-only and
use [`buf.slice`][] to create a new Buffer.
use [`buf.slice()`][] to create a new Buffer.

```js
const buf = new Buffer(10);
Expand Down Expand Up @@ -943,7 +944,7 @@ buf.toString(undefined,0,5);

* Return: {Object}

Returns a JSON representation of the Buffer instance. `JSON.stringify`
Returns a JSON representation of the Buffer instance. [`JSON.stringify()`][]
implicitly calls this function when stringifying a Buffer instance.

Example:
Expand Down Expand Up @@ -1352,11 +1353,15 @@ has observed undue memory retention in their applications.

[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
[`Array#indexOf()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
[Array#includes()]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
[`Array#includes()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
[`buf.fill(0)`]: #buffer_buf_fill_value_offset_end
[`buf.slice`]: #buffer_buf_slice_start_end
[`buf.slice()`]: #buffer_buf_slice_start_end
[`buf1.compare(buf2)`]: #buffer_buf_compare_otherbuffer
[`Buffer#slice()`]: #buffer_buf_slice_start_end
[`RangeError`]: errors.html#errors_class_rangeerror
[`String.prototype.length`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
[`util.inspect()`]: util.html#util_util_inspect_object_options
[`buf.values()`]: #buffer_buf_values
[`buf.keys()`]: #buffer_buf_keys
[`buf.entries()`]: #buffer_buf_entries
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

0 comments on commit 08d7ac4

Please sign in to comment.