From 2652ab3c4563b86ba73b8454b8ed56b36c3fbdd3 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Thu, 12 Apr 2018 01:46:48 -0400 Subject: doc: Uint8Array support in Buffer functions Buffer.from / new Buffer accept Uint8Array Fixes: https://github.com/nodejs/node/issues/14118 PR-URL: https://github.com/nodejs/node/pull/19949 Reviewed-By: Anna Henningsen Reviewed-By: Vse Mozhet Byt Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Gus Caplan --- doc/api/buffer.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'doc/api/buffer.md') diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 97bc18911a..6e6a4f77f5 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -6,9 +6,8 @@ Prior to the introduction of [`TypedArray`], the JavaScript language had no mechanism for reading or manipulating streams of binary data. The `Buffer` class -was introduced as part of the Node.js API to make it possible to interact with -octet streams in the context of things like TCP streams and file system -operations. +was introduced as part of the Node.js API to enable interaction with octet +streams in TCP streams, file system operations, and other contexts. With [`TypedArray`] now available, the `Buffer` class implements the [`Uint8Array`] API in a manner that is more optimized and suitable for Node.js. @@ -193,8 +192,8 @@ Modern Web browsers follow the [WHATWG Encoding Standard][] which aliases both `'latin1'` and `'ISO-8859-1'` to `'win-1252'`. This means that while doing something like `http.get()`, if the returned charset is one of those listed in the WHATWG specification it is possible that the server actually returned -win-1252-encoded data, and using `'latin1'` encoding may incorrectly decode the -characters. +`'win-1252'`-encoded data, and using `'latin1'` encoding may incorrectly decode +the characters. ## Buffers and TypedArray -* `buffer` {Buffer} An existing `Buffer` to copy data from. +* `buffer` {Buffer|Uint8Array} An existing `Buffer` or [`Uint8Array`] from which + to copy data. Copies the passed `buffer` data onto a new `Buffer` instance. @@ -1886,7 +1887,7 @@ added: v5.10.0 * Returns: {Buffer} A reference to `buf`. Interprets `buf` as an array of unsigned 16-bit integers and swaps the -byte-order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is +byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a multiple of 2. ```js @@ -1914,7 +1915,7 @@ added: v5.10.0 * Returns: {Buffer} A reference to `buf`. Interprets `buf` as an array of unsigned 32-bit integers and swaps the -byte-order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is +byte order *in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a multiple of 4. ```js @@ -1941,9 +1942,8 @@ added: v6.3.0 * Returns: {Buffer} A reference to `buf`. -Interprets `buf` as an array of 64-bit numbers and swaps the byte-order -*in-place*. Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a -multiple of 8. +Interprets `buf` as an array of 64-bit numbers and swaps byte order *in-place*. +Throws [`ERR_INVALID_BUFFER_SIZE`] if [`buf.length`] is not a multiple of 8. ```js const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]); -- cgit v1.2.3