@@ -138,6 +138,15 @@ extra care *must* be taken in order to avoid introducing security
138138vulnerabilities into an application.
139139
140140## Buffers and Character Encodings
141+ <!-- YAML
142+ changes:
143+ - version: v6.4.0
144+ pr-url: https://github.com/nodejs/node/pull/7111
145+ description: Introduced `latin1` as an alias for `binary`.
146+ - version: v5.0.0
147+ pr-url: https://github.com/nodejs/node/pull/2859
148+ description: Removed the deprecated `raw` and `raws` encodings.
149+ -->
141150
142151` Buffer ` instances are commonly used to represent sequences of encoded characters
143152such as UTF-8, UCS2, Base64 or even Hex-encoded data. It is possible to
@@ -188,6 +197,12 @@ that the server actually returned win-1252-encoded data, and using `'latin1'`
188197encoding may incorrectly decode the characters.
189198
190199## Buffers and TypedArray
200+ <!-- YAML
201+ changes:
202+ - version: v3.0.0
203+ pr-url: https://github.com/nodejs/node/pull/2002
204+ description: The `Buffer`s class now inherits from `Uint8Array`.
205+ -->
191206
192207` Buffer ` instances are also [ ` Uint8Array ` ] instances. However, there are subtle
193208incompatibilities with the TypedArray specification in ECMAScript 2015.
@@ -298,6 +313,13 @@ It can be constructed in a variety of ways.
298313### new Buffer(array)
299314<!-- YAML
300315deprecated: v6.0.0
316+ changes:
317+ - version: v7.2.1
318+ pr-url: https://github.com/nodejs/node/pull/9529
319+ description: Calling this constructor no longer emits a deprecation warning.
320+ - version: v7.0.0
321+ pr-url: https://github.com/nodejs/node/pull/8169
322+ description: Calling this constructor emits a deprecation warning now.
301323-->
302324
303325> Stability: 0 - Deprecated: Use [ ` Buffer.from(array) ` ] instead.
@@ -315,7 +337,18 @@ const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
315337
316338### new Buffer(arrayBuffer[ , byteOffset [ , length]] )
317339<!-- YAML
340+ added: v3.0.0
318341deprecated: v6.0.0
342+ changes:
343+ - version: v7.2.1
344+ pr-url: https://github.com/nodejs/node/pull/9529
345+ description: Calling this constructor no longer emits a deprecation warning.
346+ - version: v7.0.0
347+ pr-url: https://github.com/nodejs/node/pull/8169
348+ description: Calling this constructor emits a deprecation warning now.
349+ - version: v6.0.0
350+ pr-url: https://github.com/nodejs/node/pull/4682
351+ description: The `byteOffset` and `length` parameters are supported now.
319352-->
320353
321354> Stability: 0 - Deprecated: Use
@@ -360,6 +393,13 @@ console.log(buf);
360393### new Buffer(buffer)
361394<!-- YAML
362395deprecated: v6.0.0
396+ changes:
397+ - version: v7.2.1
398+ pr-url: https://github.com/nodejs/node/pull/9529
399+ description: Calling this constructor no longer emits a deprecation warning.
400+ - version: v7.0.0
401+ pr-url: https://github.com/nodejs/node/pull/8169
402+ description: Calling this constructor emits a deprecation warning now.
363403-->
364404
365405> Stability: 0 - Deprecated: Use [ ` Buffer.from(buffer) ` ] instead.
@@ -386,6 +426,13 @@ console.log(buf2.toString());
386426### new Buffer(size)
387427<!-- YAML
388428deprecated: v6.0.0
429+ changes:
430+ - version: v7.2.1
431+ pr-url: https://github.com/nodejs/node/pull/9529
432+ description: Calling this constructor no longer emits a deprecation warning.
433+ - version: v7.0.0
434+ pr-url: https://github.com/nodejs/node/pull/8169
435+ description: Calling this constructor emits a deprecation warning now.
389436-->
390437
391438> Stability: 0 - Deprecated: Use [ ` Buffer.alloc() ` ] instead (also see
@@ -419,6 +466,13 @@ console.log(buf);
419466### new Buffer(string[ , encoding] )
420467<!-- YAML
421468deprecated: v6.0.0
469+ changes:
470+ - version: v7.2.1
471+ pr-url: https://github.com/nodejs/node/pull/9529
472+ description: Calling this constructor no longer emits a deprecation warning.
473+ - version: v7.0.0
474+ pr-url: https://github.com/nodejs/node/pull/8169
475+ description: Calling this constructor emits a deprecation warning now.
422476-->
423477
424478> Stability: 0 - Deprecated:
@@ -508,6 +562,10 @@ A `TypeError` will be thrown if `size` is not a number.
508562### Class Method: Buffer.allocUnsafe(size)
509563<!-- YAML
510564added: v5.10.0
565+ changes:
566+ - version: v7.0.0
567+ pr-url: https://github.com/nodejs/node/pull/7079
568+ description: Passing a negative `size` will now throw an error.
511569-->
512570
513571* ` size ` {Integer} The desired length of the new ` Buffer `
@@ -606,6 +664,14 @@ A `TypeError` will be thrown if `size` is not a number.
606664### Class Method: Buffer.byteLength(string[ , encoding] )
607665<!-- YAML
608666added: v0.1.90
667+ changes:
668+ - version: v7.0.0
669+ pr-url: https://github.com/nodejs/node/pull/8946
670+ description: Passing invalid input will now throw an error.
671+ - version: v5.10.0
672+ pr-url: https://github.com/nodejs/node/pull/5255
673+ description: The `string` parameter can now be any `TypedArray`, `DataView`
674+ or `ArrayBuffer`.
609675-->
610676
611677* ` string ` {String | Buffer | TypedArray | DataView | ArrayBuffer} A value to
@@ -886,6 +952,10 @@ console.log(buf.toString('ascii'));
886952### buf.compare(target[ , targetStart[ , targetEnd[ , sourceStart[ , sourceEnd]]]] )
887953<!-- YAML
888954added: v0.11.13
955+ changes:
956+ - version: v5.11.0
957+ pr-url: https://github.com/nodejs/node/pull/5880
958+ description: Additional parameters for specifying offsets are supported now.
889959-->
890960
891961* ` target ` {Buffer} A ` Buffer ` to compare to
@@ -1066,6 +1136,10 @@ console.log(buf1.equals(buf3));
10661136### buf.fill(value[ , offset[ , end]] [ , encoding ] )
10671137<!-- YAML
10681138added: v0.5.0
1139+ changes:
1140+ - version: v5.7.0
1141+ pr-url: https://github.com/nodejs/node/pull/4935
1142+ description: The `encoding` parameter is supported now.
10691143-->
10701144
10711145* ` value ` {String | Buffer | Integer} The value to fill ` buf ` with
@@ -1144,6 +1218,11 @@ console.log(buf.includes('this', 4));
11441218### buf.indexOf(value[ , byteOffset] [ , encoding ] )
11451219<!-- YAML
11461220added: v1.5.0
1221+ changes:
1222+ - version: v5.7.0, v4.4.0
1223+ pr-url: https://github.com/nodejs/node/pull/4803
1224+ description: When `encoding` is being passed, the `byteOffset` parameter
1225+ is no longer required.
11471226-->
11481227
11491228* ` value ` {String | Buffer | Integer} What to search for
@@ -1710,6 +1789,15 @@ console.log(buf.readUIntBE(1, 6).toString(16));
17101789### buf.slice([ start[ , end]] )
17111790<!-- YAML
17121791added: v0.3.0
1792+ changes:
1793+ - version: v7.1.0, v6.9.2
1794+ pr-url: https://github.com/nodejs/node/pull/9341
1795+ description: Coercing the offsets to integers now handles values outside
1796+ the 32-bit integer range properly.
1797+ - version: v7.0.0
1798+ pr-url: https://github.com/nodejs/node/pull/9101
1799+ description: All offsets are now coerced to integers before doing any
1800+ calculations with them.
17131801-->
17141802
17151803* ` start ` {Integer} Where the new ` Buffer ` will start. ** Default:** ` 0 `
0 commit comments