Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b0c853

Browse filesBrowse files
vsemozhetbytaddaleax
authored andcommitted
doc: fix sorting in buffer.md
This PR places `Buffer.from(object...)` section before `Buffer.from(string...)` section and upper-cased bottom references before backtick-started ones. PR-URL: #25477 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
1 parent f8bb544 commit 2b0c853
Copy full SHA for 2b0c853

File tree

Expand file treeCollapse file tree

1 file changed

+28
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+28
-28
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+28-28Lines changed: 28 additions & 28 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -862,31 +862,6 @@ console.log(buf2.toString());
862862

863863
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
864864

865-
### Class Method: Buffer.from(string[, encoding])
866-
<!-- YAML
867-
added: v5.10.0
868-
-->
869-
870-
* `string` {string} A string to encode.
871-
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`.
872-
873-
Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
874-
the character encoding of `string`.
875-
876-
```js
877-
const buf1 = Buffer.from('this is a tést');
878-
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
879-
880-
console.log(buf1.toString());
881-
// Prints: this is a tést
882-
console.log(buf2.toString());
883-
// Prints: this is a tést
884-
console.log(buf1.toString('ascii'));
885-
// Prints: this is a tC)st
886-
```
887-
888-
A `TypeError` will be thrown if `string` is not a string.
889-
890865
### Class Method: Buffer.from(object[, offsetOrEncoding[, length]])
891866
<!-- YAML
892867
added: v8.2.0
@@ -921,6 +896,31 @@ const buf = Buffer.from(new Foo(), 'utf8');
921896
// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>
922897
```
923898

899+
### Class Method: Buffer.from(string[, encoding])
900+
<!-- YAML
901+
added: v5.10.0
902+
-->
903+
904+
* `string` {string} A string to encode.
905+
* `encoding` {string} The encoding of `string`. **Default:** `'utf8'`.
906+
907+
Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
908+
the character encoding of `string`.
909+
910+
```js
911+
const buf1 = Buffer.from('this is a tést');
912+
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
913+
914+
console.log(buf1.toString());
915+
// Prints: this is a tést
916+
console.log(buf2.toString());
917+
// Prints: this is a tést
918+
console.log(buf1.toString('ascii'));
919+
// Prints: this is a tC)st
920+
```
921+
922+
A `TypeError` will be thrown if `string` is not a string.
923+
924924
### Class Method: Buffer.isBuffer(obj)
925925
<!-- YAML
926926
added: v0.1.101
@@ -2642,6 +2642,9 @@ in UTF-16 code units.
26422642

26432643
This value may depend on the JS engine that is being used.
26442644

2645+
[RFC1345]: https://tools.ietf.org/html/rfc1345
2646+
[RFC4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
2647+
[WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/
26452648
[`ArrayBuffer#slice()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice
26462649
[`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer
26472650
[`Buffer.alloc()`]: #buffer_class_method_buffer_alloc_size_fill_encoding
@@ -2678,7 +2681,4 @@ This value may depend on the JS engine that is being used.
26782681
[`buffer.constants.MAX_STRING_LENGTH`]: #buffer_buffer_constants_max_string_length
26792682
[`buffer.kMaxLength`]: #buffer_buffer_kmaxlength
26802683
[`util.inspect()`]: util.html#util_util_inspect_object_options
2681-
[RFC1345]: https://tools.ietf.org/html/rfc1345
2682-
[RFC4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5
2683-
[WHATWG Encoding Standard]: https://encoding.spec.whatwg.org/
26842684
[iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.