Skip to content

Commit 4dcc692

Browse files
committedMay 4, 2016
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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 00ffa33 commit 4dcc692

File tree

1 file changed

+103
-3
lines changed

1 file changed

+103
-3
lines changed
 

Diff for: ‎doc/api/buffer.md

+103-3
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ off a shared internal memory pool if `size` is less than or equal to half
101101
use the shared internal memory pool.
102102

103103
### The `--zero-fill-buffers` command line option
104+
<!-- YAML
105+
added: v5.10.0
106+
-->
104107

105108
Node.js can be started using the `--zero-fill-buffers` command line option to
106109
force all newly allocated `Buffer` instances created using either
@@ -261,6 +264,9 @@ The Buffer class is a global type for dealing with binary data directly.
261264
It can be constructed in a variety of ways.
262265

263266
### new Buffer(array)
267+
<!-- YAML
268+
deprecated: v6.0.0
269+
-->
264270

265271
Stability: 0 - Deprecated: Use [`Buffer.from(array)`][buffer_from_array]
266272
instead.
@@ -276,6 +282,9 @@ const buf = new Buffer([0x62,0x75,0x66,0x66,0x65,0x72]);
276282
```
277283

278284
### new Buffer(buffer)
285+
<!-- YAML
286+
deprecated: v6.0.0
287+
-->
279288

280289
Stability: 0 - Deprecated: Use [`Buffer.from(buffer)`][buffer_from_buffer]
281290
instead.
@@ -296,6 +305,9 @@ console.log(buf2.toString());
296305
```
297306

298307
### new Buffer(arrayBuffer[, byteOffset [, length]])
308+
<!-- YAML
309+
deprecated: v6.0.0
310+
-->
299311

300312
Stability: 0 - Deprecated: Use
301313
[`Buffer.from(arrayBuffer[, byteOffset [, length]])`][buffer_from_arraybuf]
@@ -331,6 +343,9 @@ console.log(buf);
331343
```
332344

333345
### new Buffer(size)
346+
<!-- YAML
347+
deprecated: v6.0.0
348+
-->
334349

335350
Stability: 0 - Deprecated: Use
336351
[`Buffer.alloc(size[, fill[, encoding]])`][buffer_alloc] instead (also
@@ -360,6 +375,9 @@ console.log(buf);
360375
```
361376

362377
### new Buffer(str[, encoding])
378+
<!-- YAML
379+
deprecated: v6.0.0
380+
-->
363381

364382
Stability: 0 - Deprecated:
365383
Use [`Buffer.from(str[, encoding])`][buffer_from_string] instead.
@@ -383,6 +401,9 @@ console.log(buf2.toString());
383401
```
384402

385403
### Class Method: Buffer.alloc(size[, fill[, encoding]])
404+
<!-- YAML
405+
added: v5.10.0
406+
-->
386407

387408
* `size` {Number}
388409
* `fill` {Value} Default: `undefined`
@@ -427,6 +448,9 @@ contents will *never contain sensitive data*.
427448
A `TypeError` will be thrown if `size` is not a number.
428449

429450
### Class Method: Buffer.allocUnsafe(size)
451+
<!-- YAML
452+
added: v5.10.0
453+
-->
430454

431455
* `size` {Number}
432456

@@ -469,6 +493,9 @@ difference is subtle but can be important when an application requires the
469493
additional performance that `Buffer.allocUnsafe(size)` provides.
470494

471495
### Class Method: Buffer.allocUnsafeSlow(size)
496+
<!-- YAML
497+
added: v5.10.0
498+
-->
472499

473500
* `size` {Number}
474501

@@ -541,6 +568,9 @@ returns the actual byte length.
541568
Otherwise, converts to `String` and returns the byte length of string.
542569

543570
### Class Method: Buffer.compare(buf1, buf2)
571+
<!-- YAML
572+
added: v0.11.13
573+
-->
544574

545575
* `buf1` {Buffer}
546576
* `buf2` {Buffer}
@@ -555,6 +585,9 @@ arr.sort(Buffer.compare);
555585
```
556586

557587
### Class Method: Buffer.concat(list[, totalLength])
588+
<!-- YAML
589+
added: v0.7.11
590+
-->
558591

559592
* `list` {Array} List of Buffer objects to concat
560593
* `totalLength` {Number} Total length of the Buffers in the list
@@ -590,6 +623,9 @@ console.log(bufA.length);
590623
```
591624

592625
### Class Method: Buffer.from(array)
626+
<!-- YAML
627+
added: v3.0.0
628+
-->
593629

594630
* `array` {Array}
595631

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

606642
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
643+
<!-- YAML
644+
added: v5.10.0
645+
-->
607646

608647
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
609648
a `new ArrayBuffer()`
@@ -644,6 +683,9 @@ console.log(buf.length);
644683
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
645684

646685
### Class Method: Buffer.from(buffer)
686+
<!-- YAML
687+
added: v3.0.0
688+
-->
647689

648690
* `buffer` {Buffer}
649691

@@ -663,6 +705,9 @@ console.log(buf2.toString());
663705
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
664706

665707
### Class Method: Buffer.from(str[, encoding])
708+
<!-- YAML
709+
added: v5.10.0
710+
-->
666711

667712
* `str` {String} String to encode.
668713
* `encoding` {String} Encoding to use, Default: `'utf8'`
@@ -693,6 +738,9 @@ A `TypeError` will be thrown if `str` is not a string.
693738
Returns 'true' if `obj` is a Buffer.
694739

695740
### Class Method: Buffer.isEncoding(encoding)
741+
<!-- YAML
742+
added: v0.9.1
743+
-->
696744

697745
* `encoding` {String} The encoding string to test
698746
* Return: {Boolean}
@@ -701,9 +749,10 @@ Returns true if the `encoding` is a valid encoding argument, or false
701749
otherwise.
702750

703751
### buf[index]
704-
705-
<!--type=property-->
706-
<!--name=[index]-->
752+
<!-- YAML
753+
type: property
754+
name: [index]
755+
-->
707756

708757
The index operator `[index]` can be used to get and set the octet at position
709758
`index` in the Buffer. The values refer to individual bytes, so the legal value
@@ -724,6 +773,9 @@ console.log(buf.toString('ascii'));
724773
```
725774

726775
### buf.compare(target[, targetStart[, targetEnd[, sourceStart[, sourceEnd]]]])
776+
<!-- YAML
777+
added: v0.11.13
778+
-->
727779

728780
* `target` {Buffer}
729781
* `targetStart` {Integer} The offset within `target` at which to begin
@@ -827,6 +879,9 @@ console.log(buf.toString());
827879
```
828880

829881
### buf.entries()
882+
<!-- YAML
883+
added: v1.1.0
884+
-->
830885

831886
* Return: {Iterator}
832887

@@ -848,6 +903,9 @@ for (var pair of buf.entries()) {
848903
```
849904

850905
### buf.equals(otherBuffer)
906+
<!-- YAML
907+
added: v1.0.0
908+
-->
851909

852910
* `otherBuffer` {Buffer}
853911
* Return: {Boolean}
@@ -867,6 +925,9 @@ console.log(buf1.equals(buf3));
867925
```
868926

869927
### buf.fill(value[, offset[, end]][, encoding])
928+
<!-- YAML
929+
added: v0.5.0
930+
-->
870931

871932
* `value` {String|Buffer|Number}
872933
* `offset` {Number} Default: 0
@@ -899,6 +960,9 @@ Buffer(3).fill('\u0222');
899960
```
900961

901962
### buf.indexOf(value[, byteOffset][, encoding])
963+
<!-- YAML
964+
added: v1.5.0
965+
-->
902966

903967
* `value` {String|Buffer|Number}
904968
* `byteOffset` {Number} Default: 0
@@ -936,6 +1000,9 @@ utf16Buffer.indexOf('\u03a3', -4, 'ucs2');
9361000
```
9371001

9381002
### buf.includes(value[, byteOffset][, encoding])
1003+
<!-- YAML
1004+
added: v5.3.0
1005+
-->
9391006

9401007
* `value` {String|Buffer|Number}
9411008
* `byteOffset` {Number} Default: 0
@@ -969,6 +1036,9 @@ buf.includes('this', 4);
9691036
```
9701037

9711038
### buf.keys()
1039+
<!-- YAML
1040+
added: v1.1.0
1041+
-->
9721042

9731043
* Return: {Iterator}
9741044

@@ -989,6 +1059,9 @@ for (var key of buf.keys()) {
9891059
```
9901060

9911061
### buf.lastIndexOf(value[, byteOffset][, encoding])
1062+
<!-- YAML
1063+
added: v6.0.0
1064+
-->
9921065

9931066
* `value` {String|Buffer|Number}
9941067
* `byteOffset` {Number} Default: `buf.length`
@@ -1195,6 +1268,9 @@ buf.readInt32LE(1);
11951268

11961269
### buf.readIntBE(offset, byteLength[, noAssert])
11971270
### buf.readIntLE(offset, byteLength[, noAssert])
1271+
<!-- YAML
1272+
added: v1.0.0
1273+
-->
11981274

11991275
* `offset` {Number} `0 <= offset <= buf.length - byteLength`
12001276
* `byteLength` {Number} `0 < byteLength <= 6`
@@ -1299,6 +1375,9 @@ console.log(buf.readUInt32LE(0));
12991375

13001376
### buf.readUIntBE(offset, byteLength[, noAssert])
13011377
### buf.readUIntLE(offset, byteLength[, noAssert])
1378+
<!-- YAML
1379+
added: v1.0.0
1380+
-->
13021381

13031382
* `offset` {Number} `0 <= offset <= buf.length - byteLength`
13041383
* `byteLength` {Number} `0 < byteLength <= 6`
@@ -1368,6 +1447,9 @@ buf.slice(-5, -2).toString();
13681447
```
13691448

13701449
### buf.swap16()
1450+
<!-- YAML
1451+
added: v5.10.0
1452+
-->
13711453

13721454
* Return: {Buffer}
13731455

@@ -1386,6 +1468,9 @@ console.log(buf);
13861468
```
13871469

13881470
### buf.swap32()
1471+
<!-- YAML
1472+
added: v5.10.0
1473+
-->
13891474

13901475
* Return: {Buffer}
13911476

@@ -1429,6 +1514,9 @@ buf.toString(undefined,0,5);
14291514
```
14301515

14311516
### buf.toJSON()
1517+
<!-- YAML
1518+
added: v0.9.2
1519+
-->
14321520

14331521
* Return: {Object}
14341522

@@ -1455,6 +1543,9 @@ console.log(copy.toString());
14551543
```
14561544

14571545
### buf.values()
1546+
<!-- YAML
1547+
added: v1.1.0
1548+
-->
14581549

14591550
* Return: {Iterator}
14601551

@@ -1657,6 +1748,9 @@ console.log(buf);
16571748

16581749
### buf.writeIntBE(value, offset, byteLength[, noAssert])
16591750
### buf.writeIntLE(value, offset, byteLength[, noAssert])
1751+
<!-- YAML
1752+
added: v1.0.0
1753+
-->
16601754

16611755
* `value` {Number} Bytes to be written to Buffer
16621756
* `offset` {Number} `0 <= offset <= buf.length - byteLength`
@@ -1821,6 +1915,9 @@ Note that this is a property on the `buffer` module as returned by
18211915
`require('buffer')`, not on the Buffer global or a Buffer instance.
18221916

18231917
## Class: SlowBuffer
1918+
<!-- YAML
1919+
deprecated: v6.0.0
1920+
-->
18241921

18251922
Stability: 0 - Deprecated: Use
18261923
[`Buffer.allocUnsafeSlow(size)`][buffer_allocunsafeslow] instead.
@@ -1854,6 +1951,9 @@ Use of `SlowBuffer` should be used only as a last resort *after* a developer
18541951
has observed undue memory retention in their applications.
18551952

18561953
### new SlowBuffer(size)
1954+
<!-- YAML
1955+
deprecated: v6.0.0
1956+
-->
18571957

18581958
Stability: 0 - Deprecated: Use
18591959
[`Buffer.allocUnsafeSlow(size)`][buffer_allocunsafeslow] instead.

0 commit comments

Comments
 (0)
Please sign in to comment.