@@ -138,6 +138,15 @@ extra care *must* be taken in order to avoid introducing security
138
138
vulnerabilities into an application.
139
139
140
140
## 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
+ -->
141
150
142
151
` Buffer ` instances are commonly used to represent sequences of encoded characters
143
152
such 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'`
188
197
encoding may incorrectly decode the characters.
189
198
190
199
## 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
+ -->
191
206
192
207
` Buffer ` instances are also [ ` Uint8Array ` ] instances. However, there are subtle
193
208
incompatibilities with the TypedArray specification in ECMAScript 2015.
@@ -298,6 +313,13 @@ It can be constructed in a variety of ways.
298
313
### new Buffer(array)
299
314
<!-- YAML
300
315
deprecated: 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.
301
323
-->
302
324
303
325
> Stability: 0 - Deprecated: Use [ ` Buffer.from(array) ` ] instead.
@@ -315,7 +337,18 @@ const buf = new Buffer([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
315
337
316
338
### new Buffer(arrayBuffer[ , byteOffset [ , length]] )
317
339
<!-- YAML
340
+ added: v3.0.0
318
341
deprecated: 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.
319
352
-->
320
353
321
354
> Stability: 0 - Deprecated: Use
@@ -360,6 +393,13 @@ console.log(buf);
360
393
### new Buffer(buffer)
361
394
<!-- YAML
362
395
deprecated: 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.
363
403
-->
364
404
365
405
> Stability: 0 - Deprecated: Use [ ` Buffer.from(buffer) ` ] instead.
@@ -386,6 +426,13 @@ console.log(buf2.toString());
386
426
### new Buffer(size)
387
427
<!-- YAML
388
428
deprecated: 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.
389
436
-->
390
437
391
438
> Stability: 0 - Deprecated: Use [ ` Buffer.alloc() ` ] instead (also see
@@ -419,6 +466,13 @@ console.log(buf);
419
466
### new Buffer(string[ , encoding] )
420
467
<!-- YAML
421
468
deprecated: 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.
422
476
-->
423
477
424
478
> Stability: 0 - Deprecated:
@@ -508,6 +562,10 @@ A `TypeError` will be thrown if `size` is not a number.
508
562
### Class Method: Buffer.allocUnsafe(size)
509
563
<!-- YAML
510
564
added: 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.
511
569
-->
512
570
513
571
* ` size ` {Integer} The desired length of the new ` Buffer `
@@ -606,6 +664,14 @@ A `TypeError` will be thrown if `size` is not a number.
606
664
### Class Method: Buffer.byteLength(string[ , encoding] )
607
665
<!-- YAML
608
666
added: 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`.
609
675
-->
610
676
611
677
* ` string ` {String | Buffer | TypedArray | DataView | ArrayBuffer} A value to
@@ -886,6 +952,10 @@ console.log(buf.toString('ascii'));
886
952
### buf.compare(target[ , targetStart[ , targetEnd[ , sourceStart[ , sourceEnd]]]] )
887
953
<!-- YAML
888
954
added: 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.
889
959
-->
890
960
891
961
* ` target ` {Buffer} A ` Buffer ` to compare to
@@ -1066,6 +1136,10 @@ console.log(buf1.equals(buf3));
1066
1136
### buf.fill(value[ , offset[ , end]] [ , encoding ] )
1067
1137
<!-- YAML
1068
1138
added: 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.
1069
1143
-->
1070
1144
1071
1145
* ` value ` {String | Buffer | Integer} The value to fill ` buf ` with
@@ -1144,6 +1218,11 @@ console.log(buf.includes('this', 4));
1144
1218
### buf.indexOf(value[ , byteOffset] [ , encoding ] )
1145
1219
<!-- YAML
1146
1220
added: 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.
1147
1226
-->
1148
1227
1149
1228
* ` value ` {String | Buffer | Integer} What to search for
@@ -1710,6 +1789,15 @@ console.log(buf.readUIntBE(1, 6).toString(16));
1710
1789
### buf.slice([ start[ , end]] )
1711
1790
<!-- YAML
1712
1791
added: 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.
1713
1801
-->
1714
1802
1715
1803
* ` start ` {Integer} Where the new ` Buffer ` will start. ** Default:** ` 0 `
0 commit comments