Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ec25f38

Browse filesBrowse files
addaleaxMyles Borins
authored andcommitted
doc: add added: information for buffer
Add `added:` and `deprecated:` entries to buffer.md. These are incomplete (particularly for some of the ancient features), but correct to the best of my knowledge. This serves as a demonstration of how the `added:`/`deprecated:` metadata may be implemented in 'real' docs. PR-URL: #6495 Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 1e86d16 commit ec25f38
Copy full SHA for ec25f38

File tree

Expand file treeCollapse file tree

1 file changed

+67
-36
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+67
-36
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.md‎

Copy file name to clipboardExpand all lines: doc/api/buffer.md
+67-36Lines changed: 67 additions & 36 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ console.log(buf2.toString());
378378
```
379379

380380
### Class Method: Buffer.alloc(size[, fill[, encoding]])
381+
<!-- YAML
382+
added: v4.5.0
383+
-->
381384

382385
* `size` {Number}
383386
* `fill` {Value} Default: `undefined`
@@ -422,6 +425,9 @@ contents will *never contain sensitive data*.
422425
A `TypeError` will be thrown if `size` is not a number.
423426

424427
### Class Method: Buffer.allocUnsafe(size)
428+
<!-- YAML
429+
added: v4.5.0
430+
-->
425431

426432
* `size` {Number}
427433

@@ -464,6 +470,9 @@ difference is subtle but can be important when an application requires the
464470
additional performance that `Buffer.allocUnsafe(size)` provides.
465471

466472
### Class Method: Buffer.allocUnsafeSlow(size)
473+
<!-- YAML
474+
added: v4.5.0
475+
-->
467476

468477
* `size` {Number}
469478

@@ -531,6 +540,9 @@ console.log(`${str}: ${str.length} characters, ` +
531540
```
532541

533542
### Class Method: Buffer.compare(buf1, buf2)
543+
<!-- YAML
544+
added: v0.11.13
545+
-->
534546

535547
* `buf1` {Buffer}
536548
* `buf2` {Buffer}
@@ -545,6 +557,9 @@ arr.sort(Buffer.compare);
545557
```
546558

547559
### Class Method: Buffer.concat(list[, totalLength])
560+
<!-- YAML
561+
added: v0.7.11
562+
-->
548563

549564
* `list` {Array} List of Buffer objects to concat
550565
* `totalLength` {Number} Total length of the Buffers in the list when concatenated
@@ -579,6 +594,9 @@ console.log(bufA.length);
579594
```
580595

581596
### Class Method: Buffer.from(array)
597+
<!-- YAML
598+
added: v3.0.0
599+
-->
582600

583601
* `array` {Array}
584602

@@ -593,6 +611,9 @@ const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
593611
A `TypeError` will be thrown if `array` is not an `Array`.
594612

595613
### Class Method: Buffer.from(arrayBuffer)
614+
<!-- YAML
615+
added: v4.5.0
616+
-->
596617

597618
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
598619
a `new ArrayBuffer()`
@@ -621,6 +642,9 @@ console.log(buf);
621642
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
622643

623644
### Class Method: Buffer.from(buffer)
645+
<!-- YAML
646+
added: v3.0.0
647+
-->
624648

625649
* `buffer` {Buffer}
626650

@@ -640,6 +664,9 @@ console.log(buf2.toString());
640664
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
641665

642666
### Class Method: Buffer.from(str[, encoding])
667+
<!-- YAML
668+
added: v4.5.0
669+
-->
643670

644671
* `str` {String} String to encode.
645672
* `encoding` {String} Encoding to use, Default: `'utf8'`
@@ -670,6 +697,9 @@ A `TypeError` will be thrown if `str` is not a string.
670697
Returns 'true' if `obj` is a Buffer.
671698

672699
### Class Method: Buffer.isEncoding(encoding)
700+
<!-- YAML
701+
added: v0.9.1
702+
-->
673703

674704
* `encoding` {String} The encoding string to test
675705
* Return: {Boolean}
@@ -678,9 +708,10 @@ Returns true if the `encoding` is a valid encoding argument, or false
678708
otherwise.
679709

680710
### buf[index]
681-
682-
<!--type=property-->
683-
<!--name=[index]-->
711+
<!-- YAML
712+
type: property
713+
name: [index]
714+
-->
684715

685716
The index operator `[index]` can be used to get and set the octet at position
686717
`index` in the Buffer. The values refer to individual bytes, so the legal value
@@ -701,6 +732,9 @@ console.log(buf.toString('ascii'));
701732
```
702733

703734
### buf.compare(otherBuffer)
735+
<!-- YAML
736+
added: v0.11.13
737+
-->
704738

705739
* `otherBuffer` {Buffer}
706740
* Return: {Number}
@@ -777,6 +811,9 @@ console.log(buf.toString());
777811
```
778812

779813
### buf.entries()
814+
<!-- YAML
815+
added: v1.1.0
816+
-->
780817

781818
* Return: {Iterator}
782819

@@ -798,6 +835,9 @@ for (var pair of buf.entries()) {
798835
```
799836

800837
### buf.equals(otherBuffer)
838+
<!-- YAML
839+
added: v1.0.0
840+
-->
801841

802842
* `otherBuffer` {Buffer}
803843
* Return: {Boolean}
@@ -817,6 +857,9 @@ console.log(buf1.equals(buf3));
817857
```
818858

819859
### buf.fill(value[, offset[, end]])
860+
<!-- YAML
861+
added: v0.5.0
862+
-->
820863

821864
* `value` {String|Number}
822865
* `offset` {Number} Default: 0
@@ -834,6 +877,9 @@ console.log(b.toString());
834877
```
835878

836879
### buf.indexOf(value[, byteOffset][, encoding])
880+
<!-- YAML
881+
added: v1.5.0
882+
-->
837883

838884
* `value` {String|Buffer|Number}
839885
* `byteOffset` {Number} Default: 0
@@ -870,40 +916,10 @@ utf16Buffer.indexOf('\u03a3', -4, 'ucs2');
870916
// returns 6
871917
```
872918

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-
906919
### buf.keys()
920+
<!-- YAML
921+
added: v1.1.0
922+
-->
907923

908924
* Return: {Iterator}
909925

@@ -1090,6 +1106,9 @@ buf.readInt32LE(1);
10901106

10911107
### buf.readIntBE(offset, byteLength[, noAssert])
10921108
### buf.readIntLE(offset, byteLength[, noAssert])
1109+
<!-- YAML
1110+
added: v1.0.0
1111+
-->
10931112

10941113
* `offset` {Number} `0 <= offset <= buf.length - byteLength`
10951114
* `byteLength` {Number} `0 < byteLength <= 6`
@@ -1194,6 +1213,9 @@ console.log(buf.readUInt32LE(0));
11941213

11951214
### buf.readUIntBE(offset, byteLength[, noAssert])
11961215
### buf.readUIntLE(offset, byteLength[, noAssert])
1216+
<!-- YAML
1217+
added: v1.0.0
1218+
-->
11971219

11981220
* `offset` {Number} `0 <= offset <= buf.length - byteLength`
11991221
* `byteLength` {Number} `0 < byteLength <= 6`
@@ -1288,6 +1310,9 @@ buf.toString(undefined,0,5);
12881310
```
12891311

12901312
### buf.toJSON()
1313+
<!-- YAML
1314+
added: v0.9.2
1315+
-->
12911316

12921317
* Return: {Object}
12931318

@@ -1314,6 +1339,9 @@ console.log(copy.toString());
13141339
```
13151340

13161341
### buf.values()
1342+
<!-- YAML
1343+
added: v1.1.0
1344+
-->
13171345

13181346
* Return: {Iterator}
13191347

@@ -1516,6 +1544,9 @@ console.log(buf);
15161544

15171545
### buf.writeIntBE(value, offset, byteLength[, noAssert])
15181546
### buf.writeIntLE(value, offset, byteLength[, noAssert])
1547+
<!-- YAML
1548+
added: v1.0.0
1549+
-->
15191550

15201551
* `value` {Number} Bytes to be written to Buffer
15211552
* `offset` {Number} `0 <= offset <= buf.length - byteLength`

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.