@@ -378,6 +378,9 @@ console.log(buf2.toString());
378
378
```
379
379
380
380
### Class Method: Buffer.alloc(size[ , fill[ , encoding]] )
381
+ <!-- YAML
382
+ added: v4.5.0
383
+ -->
381
384
382
385
* ` size ` {Number}
383
386
* ` fill ` {Value} Default: ` undefined `
@@ -422,6 +425,9 @@ contents will *never contain sensitive data*.
422
425
A ` TypeError ` will be thrown if ` size ` is not a number.
423
426
424
427
### Class Method: Buffer.allocUnsafe(size)
428
+ <!-- YAML
429
+ added: v4.5.0
430
+ -->
425
431
426
432
* ` size ` {Number}
427
433
@@ -464,6 +470,9 @@ difference is subtle but can be important when an application requires the
464
470
additional performance that ` Buffer.allocUnsafe(size) ` provides.
465
471
466
472
### Class Method: Buffer.allocUnsafeSlow(size)
473
+ <!-- YAML
474
+ added: v4.5.0
475
+ -->
467
476
468
477
* ` size ` {Number}
469
478
@@ -531,6 +540,9 @@ console.log(`${str}: ${str.length} characters, ` +
531
540
```
532
541
533
542
### Class Method: Buffer.compare(buf1, buf2)
543
+ <!-- YAML
544
+ added: v0.11.13
545
+ -->
534
546
535
547
* ` buf1 ` {Buffer}
536
548
* ` buf2 ` {Buffer}
@@ -545,6 +557,9 @@ arr.sort(Buffer.compare);
545
557
```
546
558
547
559
### Class Method: Buffer.concat(list[ , totalLength] )
560
+ <!-- YAML
561
+ added: v0.7.11
562
+ -->
548
563
549
564
* ` list ` {Array} List of Buffer objects to concat
550
565
* ` totalLength ` {Number} Total length of the Buffers in the list when concatenated
@@ -579,6 +594,9 @@ console.log(bufA.length);
579
594
```
580
595
581
596
### Class Method: Buffer.from(array)
597
+ <!-- YAML
598
+ added: v3.0.0
599
+ -->
582
600
583
601
* ` array ` {Array}
584
602
@@ -593,6 +611,9 @@ const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
593
611
A ` TypeError ` will be thrown if ` array ` is not an ` Array ` .
594
612
595
613
### Class Method: Buffer.from(arrayBuffer)
614
+ <!-- YAML
615
+ added: v4.5.0
616
+ -->
596
617
597
618
* ` arrayBuffer ` {ArrayBuffer} The ` .buffer ` property of a ` TypedArray ` or
598
619
a ` new ArrayBuffer() `
@@ -621,6 +642,9 @@ console.log(buf);
621
642
A ` TypeError ` will be thrown if ` arrayBuffer ` is not an ` ArrayBuffer ` .
622
643
623
644
### Class Method: Buffer.from(buffer)
645
+ <!-- YAML
646
+ added: v3.0.0
647
+ -->
624
648
625
649
* ` buffer ` {Buffer}
626
650
@@ -640,6 +664,9 @@ console.log(buf2.toString());
640
664
A ` TypeError ` will be thrown if ` buffer ` is not a ` Buffer ` .
641
665
642
666
### Class Method: Buffer.from(str[ , encoding] )
667
+ <!-- YAML
668
+ added: v4.5.0
669
+ -->
643
670
644
671
* ` str ` {String} String to encode.
645
672
* ` encoding ` {String} Encoding to use, Default: ` 'utf8' `
@@ -670,6 +697,9 @@ A `TypeError` will be thrown if `str` is not a string.
670
697
Returns 'true' if ` obj ` is a Buffer.
671
698
672
699
### Class Method: Buffer.isEncoding(encoding)
700
+ <!-- YAML
701
+ added: v0.9.1
702
+ -->
673
703
674
704
* ` encoding ` {String} The encoding string to test
675
705
* Return: {Boolean}
@@ -678,9 +708,10 @@ Returns true if the `encoding` is a valid encoding argument, or false
678
708
otherwise.
679
709
680
710
### buf[ index]
681
-
682
- <!-- type=property-->
683
- <!-- name=[index]-->
711
+ <!-- YAML
712
+ type: property
713
+ name: [index]
714
+ -->
684
715
685
716
The index operator ` [index] ` can be used to get and set the octet at position
686
717
` index ` in the Buffer. The values refer to individual bytes, so the legal value
@@ -701,6 +732,9 @@ console.log(buf.toString('ascii'));
701
732
```
702
733
703
734
### buf.compare(otherBuffer)
735
+ <!-- YAML
736
+ added: v0.11.13
737
+ -->
704
738
705
739
* ` otherBuffer ` {Buffer}
706
740
* Return: {Number}
@@ -777,6 +811,9 @@ console.log(buf.toString());
777
811
```
778
812
779
813
### buf.entries()
814
+ <!-- YAML
815
+ added: v1.1.0
816
+ -->
780
817
781
818
* Return: {Iterator}
782
819
@@ -798,6 +835,9 @@ for (var pair of buf.entries()) {
798
835
```
799
836
800
837
### buf.equals(otherBuffer)
838
+ <!-- YAML
839
+ added: v1.0.0
840
+ -->
801
841
802
842
* ` otherBuffer ` {Buffer}
803
843
* Return: {Boolean}
@@ -817,6 +857,9 @@ console.log(buf1.equals(buf3));
817
857
```
818
858
819
859
### buf.fill(value[ , offset[ , end]] )
860
+ <!-- YAML
861
+ added: v0.5.0
862
+ -->
820
863
821
864
* ` value ` {String|Number}
822
865
* ` offset ` {Number} Default: 0
@@ -834,6 +877,9 @@ console.log(b.toString());
834
877
```
835
878
836
879
### buf.indexOf(value[ , byteOffset] [ , encoding ] )
880
+ <!-- YAML
881
+ added: v1.5.0
882
+ -->
837
883
838
884
* ` value ` {String|Buffer|Number}
839
885
* ` byteOffset ` {Number} Default: 0
@@ -870,40 +916,10 @@ utf16Buffer.indexOf('\u03a3', -4, 'ucs2');
870
916
// returns 6
871
917
```
872
918
873
- ### buf.includes(value[ , byteOffset] [ , encoding ] )
874
-
875
- * ` value ` {String|Buffer|Number}
876
- * ` byteOffset ` {Number} Default: 0
877
- * ` encoding ` {String} Default: ` 'utf8' `
878
- * Return: {Boolean}
879
-
880
- Operates similar to [ ` Array#includes() ` ] [ ] . The ` value ` can be a String, Buffer
881
- or Number. Strings are interpreted as UTF8 unless overridden with the
882
- ` encoding ` argument. Buffers will use the entire Buffer (to compare a partial
883
- Buffer use [ ` buf.slice() ` ] [ ] ). Numbers can range from 0 to 255.
884
-
885
- The ` byteOffset ` indicates the index in ` buf ` where searching begins.
886
-
887
- ``` js
888
- const buf = new Buffer (' this is a buffer' );
889
-
890
- buf .includes (' this' );
891
- // returns true
892
- buf .includes (' is' );
893
- // returns true
894
- buf .includes (new Buffer (' a buffer' ));
895
- // returns true
896
- buf .includes (97 ); // ascii for 'a'
897
- // returns true
898
- buf .includes (new Buffer (' a buffer example' ));
899
- // returns false
900
- buf .includes (new Buffer (' a buffer example' ).slice (0 ,8 ));
901
- // returns true
902
- buf .includes (' this' , 4 );
903
- // returns false
904
- ```
905
-
906
919
### buf.keys()
920
+ <!-- YAML
921
+ added: v1.1.0
922
+ -->
907
923
908
924
* Return: {Iterator}
909
925
@@ -1090,6 +1106,9 @@ buf.readInt32LE(1);
1090
1106
1091
1107
### buf.readIntBE(offset, byteLength[ , noAssert] )
1092
1108
### buf.readIntLE(offset, byteLength[ , noAssert] )
1109
+ <!-- YAML
1110
+ added: v1.0.0
1111
+ -->
1093
1112
1094
1113
* ` offset ` {Number} ` 0 <= offset <= buf.length - byteLength `
1095
1114
* ` byteLength ` {Number} ` 0 < byteLength <= 6 `
@@ -1194,6 +1213,9 @@ console.log(buf.readUInt32LE(0));
1194
1213
1195
1214
### buf.readUIntBE(offset, byteLength[ , noAssert] )
1196
1215
### buf.readUIntLE(offset, byteLength[ , noAssert] )
1216
+ <!-- YAML
1217
+ added: v1.0.0
1218
+ -->
1197
1219
1198
1220
* ` offset ` {Number} ` 0 <= offset <= buf.length - byteLength `
1199
1221
* ` byteLength ` {Number} ` 0 < byteLength <= 6 `
@@ -1288,6 +1310,9 @@ buf.toString(undefined,0,5);
1288
1310
```
1289
1311
1290
1312
### buf.toJSON()
1313
+ <!-- YAML
1314
+ added: v0.9.2
1315
+ -->
1291
1316
1292
1317
* Return: {Object}
1293
1318
@@ -1314,6 +1339,9 @@ console.log(copy.toString());
1314
1339
```
1315
1340
1316
1341
### buf.values()
1342
+ <!-- YAML
1343
+ added: v1.1.0
1344
+ -->
1317
1345
1318
1346
* Return: {Iterator}
1319
1347
@@ -1516,6 +1544,9 @@ console.log(buf);
1516
1544
1517
1545
### buf.writeIntBE(value, offset, byteLength[ , noAssert] )
1518
1546
### buf.writeIntLE(value, offset, byteLength[ , noAssert] )
1547
+ <!-- YAML
1548
+ added: v1.0.0
1549
+ -->
1519
1550
1520
1551
* ` value ` {Number} Bytes to be written to Buffer
1521
1552
* ` offset ` {Number} ` 0 <= offset <= buf.length - byteLength `
0 commit comments