@@ -243,7 +243,7 @@ changes:
243243-->
244244
245245` Buffer ` instances are also JavaScript {Uint8Array} and {TypedArray}
246- instances. All {TypedArray} methods are available on ` Buffer ` s. There are,
246+ instances. All {TypedArray} methods and properties are available on ` Buffer ` s. There are,
247247however, subtle incompatibilities between the ` Buffer ` API and the
248248{TypedArray} API.
249249
@@ -415,6 +415,21 @@ function:
415415* [ ` Buffer.from(arrayBuffer[, byteOffset[, length]]) ` ] [ `Buffer.from(arrayBuf)` ]
416416* [ ` Buffer.from(string[, encoding]) ` ] [ `Buffer.from(string)` ]
417417
418+ ### Buffer methods are callable with ` Uint8Array ` instances
419+
420+ All methods on the Buffer prototype are callable with a ` Uint8Array ` instance.
421+
422+ ``` js
423+ const { toString , write } = Buffer .prototype ;
424+
425+ const uint8array = new Uint8Array (5 );
426+
427+ write .call (uint8array, ' hello' , 0 , 5 , ' utf8' ); // 5
428+ // <Uint8Array 68 65 6c 6c 6f>
429+
430+ toString .call (uint8array, ' utf8' ); // 'hello'
431+ ```
432+
418433## Buffers and iteration
419434
420435` Buffer ` instances can be iterated over using ` for..of ` syntax:
@@ -2058,6 +2073,10 @@ console.log(buf.fill('zz', 'hex'));
20582073
20592074<!-- YAML
20602075added: v5.3.0
2076+ changes:
2077+ - version: REPLACEME
2078+ pr-url: https://github.com/nodejs/node/pull/56578
2079+ description: supports Uint8Array as `this` value.
20612080-->
20622081
20632082* ` value ` {string|Buffer|Uint8Array|integer} What to search for.
@@ -2945,10 +2964,14 @@ console.log(buf.readInt32LE(1));
29452964<!-- YAML
29462965added: v0.11.15
29472966changes:
2967+ - version: REPLACEME
2968+ pr-url: https://github.com/nodejs/node/pull/56578
2969+ description: supports Uint8Array as `this` value.
29482970 - version: v10.0.0
29492971 pr-url: https://github.com/nodejs/node/pull/18395
29502972 description: Removed `noAssert` and no implicit coercion of the offset
29512973 and `byteLength` to `uint32` anymore.
2974+
29522975-->
29532976
29542977* ` offset ` {integer} Number of bytes to skip before starting to read. Must
@@ -2992,10 +3015,14 @@ console.log(buf.readIntBE(1, 0).toString(16));
29923015<!-- YAML
29933016added: v0.11.15
29943017changes:
3018+ - version: REPLACEME
3019+ pr-url: https://github.com/nodejs/node/pull/56578
3020+ description: supports Uint8Array as `this` value.
29953021 - version: v10.0.0
29963022 pr-url: https://github.com/nodejs/node/pull/18395
29973023 description: Removed `noAssert` and no implicit coercion of the offset
29983024 and `byteLength` to `uint32` anymore.
3025+
29993026-->
30003027
30013028* ` offset ` {integer} Number of bytes to skip before starting to read. Must
@@ -3269,6 +3296,9 @@ console.log(buf.readUInt32LE(1).toString(16));
32693296<!-- YAML
32703297added: v0.11.15
32713298changes:
3299+ - version: REPLACEME
3300+ pr-url: https://github.com/nodejs/node/pull/56578
3301+ description: supports Uint8Array as `this` value.
32723302 - version:
32733303 - v14.9.0
32743304 - v12.19.0
@@ -3319,6 +3349,9 @@ console.log(buf.readUIntBE(1, 6).toString(16));
33193349<!-- YAML
33203350added: v0.11.15
33213351changes:
3352+ - version: REPLACEME
3353+ pr-url: https://github.com/nodejs/node/pull/56578
3354+ description: supports Uint8Array as `this` value.
33223355 - version:
33233356 - v14.9.0
33243357 - v12.19.0
@@ -3771,6 +3804,10 @@ console.log(copy);
37713804
37723805<!-- YAML
37733806added: v0.1.90
3807+ changes:
3808+ - version: REPLACEME
3809+ pr-url: https://github.com/nodejs/node/pull/56578
3810+ description: supports Uint8Array as `this` value.
37743811-->
37753812
37763813* ` encoding ` {string} The character encoding to use. ** Default:** ` 'utf8' ` .
@@ -3909,6 +3946,10 @@ for (const value of buf) {
39093946
39103947<!-- YAML
39113948added: v0.1.90
3949+ changes:
3950+ - version: REPLACEME
3951+ pr-url: https://github.com/nodejs/node/pull/56578
3952+ description: supports Uint8Array as `this` value.
39123953-->
39133954
39143955* ` string ` {string} String to write to ` buf ` .
0 commit comments