doc: fix error notes in Buffer.from() variants · nodejs/node@c3d573d (original) (raw)

`` @@ -787,7 +787,8 @@ Allocates a new Buffer using an array of octets.

``

787

787

`const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);

`

788

788

```` ```


`789`

`789`

``

`790`

``

`` -

A `TypeError` will be thrown if `array` is not an `Array`.

``

``

`790`

`` +

A `TypeError` will be thrown if `array` is not an `Array` or other type

``

``

`791`

`` +

appropriate for `Buffer.from()` variants.

``

`791`

`792`

``

`792`

`793`

`### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])

`

`793`

`794`

`<!-- YAML

`

`@@ -836,7 +837,7 @@ console.log(buf.length);

`

`836`

`837`

```` ```

837

838

``

838

839

`` A TypeError will be thrown if arrayBuffer is not an [ArrayBuffer] or a

``

839

``

`` -

[SharedArrayBuffer].

``

``

840

`` +

[SharedArrayBuffer] or other type appropriate for Buffer.from() variants.

``

840

841

``

841

842

`### Class Method: Buffer.from(buffer)

`

842

843

`<!-- YAML

`

`@@ -860,7 +861,8 @@ console.log(buf2.toString());

`

860

861

`// Prints: buffer

`

861

862

```` ```


`862`

`863`

``

`863`

``

`` -

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

``

``

`864`

`` +

A `TypeError` will be thrown if `buffer` is not a `Buffer` or other type

``

``

`865`

`` +

appropriate for `Buffer.from()` variants.

``

`864`

`866`

``

`865`

`867`

`### Class Method: Buffer.from(object[, offsetOrEncoding[, length]])

`

`866`

`868`

`<!-- YAML

`

`@@ -896,6 +898,9 @@ const buf = Buffer.from(new Foo(), 'utf8');

`

`896`

`898`

`// Prints: <Buffer 74 68 69 73 20 69 73 20 61 20 74 65 73 74>

`

`897`

`899`

```` ```

898

900

``

``

901

`` +

A TypeError will be thrown if object has not mentioned methods or is not of

``

``

902

`` +

other type appropriate for Buffer.from() variants.

``

``

903

+

899

904

`### Class Method: Buffer.from(string[, encoding])

`

900

905

`<!-- YAML

`

901

906

`added: v5.10.0

`

`@@ -919,7 +924,8 @@ console.log(buf1.toString('ascii'));

`

919

924

`// Prints: this is a tC)st

`

920

925

```` ```

````

921

926

``

922

``

`` -

A TypeError will be thrown if string is not a string.

``

``

927

`` +

A TypeError will be thrown if string is not a string or other type

``

``

928

`` +

appropriate for Buffer.from() variants.

``

923

929

``

924

930

`### Class Method: Buffer.isBuffer(obj)

`

925

931

`<!-- YAML

`