From 9cf1370017c1bfabb6c60d51bec0b3e9b8c0194d Mon Sep 17 00:00:00 2001 From: Alexander Makarenko Date: Sun, 31 Jan 2016 16:25:59 +0300 Subject: [PATCH] doc: improve styling consistency in Buffer docs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add links style consistency. PR-URL: https://github.com/nodejs/node/pull/5001 Reviewed-By: Michaƫl Zasso Reviewed-By: Roman Klauke Reviewed-By: James M Snell --- doc/api/buffer.markdown | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 9296c5b65bf71a..c4a139d8308a42 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -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); @@ -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 @@ -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')]; @@ -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'); @@ -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. @@ -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); @@ -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: @@ -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