summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorVse Mozhet Byt <vsemozhetbyt@gmail.com>2019-03-30 20:45:19 +0200
committerVse Mozhet Byt <vsemozhetbyt@gmail.com>2019-04-03 00:51:10 +0300
commite4c6c3bf2e6f8ee8f2d1d9b95fc731a5ac224fdf (patch)
treee359c5c80b3ed63037e7aa3fba4eb060a7e9df93 /doc
parent2f338f3fa1ded597b8a8aa618e4fb09d87d6e45b (diff)
downloadandroid-node-v8-e4c6c3bf2e6f8ee8f2d1d9b95fc731a5ac224fdf.tar.gz
android-node-v8-e4c6c3bf2e6f8ee8f2d1d9b95fc731a5ac224fdf.tar.bz2
android-node-v8-e4c6c3bf2e6f8ee8f2d1d9b95fc731a5ac224fdf.zip
doc: fix error notes in `Buffer.from()` variants
Make notes about `TypeError` conditions in `Buffer.from()` variants more accurate. PR-URL: https://github.com/nodejs/node/pull/27030 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/buffer.md14
1 files changed, 10 insertions, 4 deletions
diff --git a/doc/api/buffer.md b/doc/api/buffer.md
index 969668dd7a..afeef8b3c2 100644
--- a/doc/api/buffer.md
+++ b/doc/api/buffer.md
@@ -787,7 +787,8 @@ Allocates a new `Buffer` using an `array` of octets.
const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
```
-A `TypeError` will be thrown if `array` is not an `Array`.
+A `TypeError` will be thrown if `array` is not an `Array` or other type
+appropriate for `Buffer.from()` variants.
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
<!-- YAML
@@ -836,7 +837,7 @@ console.log(buf.length);
```
A `TypeError` will be thrown if `arrayBuffer` is not an [`ArrayBuffer`] or a
-[`SharedArrayBuffer`].
+[`SharedArrayBuffer`] or other type appropriate for `Buffer.from()` variants.
### Class Method: Buffer.from(buffer)
<!-- YAML
@@ -860,7 +861,8 @@ console.log(buf2.toString());
// Prints: buffer
```
-A `TypeError` will be thrown if `buffer` is not a `Buffer`.
+A `TypeError` will be thrown if `buffer` is not a `Buffer` or other type
+appropriate for `Buffer.from()` variants.
### Class Method: Buffer.from(object[, offsetOrEncoding[, length]])
<!-- YAML
@@ -896,6 +898,9 @@ const buf = Buffer.from(new Foo(), 'utf8');
// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>
```
+A `TypeError` will be thrown if `object` has not mentioned methods or is not of
+other type appropriate for `Buffer.from()` variants.
+
### Class Method: Buffer.from(string[, encoding])
<!-- YAML
added: v5.10.0
@@ -919,7 +924,8 @@ console.log(buf1.toString('ascii'));
// Prints: this is a tC)st
```
-A `TypeError` will be thrown if `string` is not a string.
+A `TypeError` will be thrown if `string` is not a string or other type
+appropriate for `Buffer.from()` variants.
### Class Method: Buffer.isBuffer(obj)
<!-- YAML