Skip to content

Commit

Permalink
doc: document buffer's "Uint" aliases clearly
Browse files Browse the repository at this point in the history
Fixes: #36751

PR-URL: #36796
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Harshitha K P <harshitha014@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
targos committed May 1, 2021
1 parent 5f36ff8 commit cf0fa7f
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions doc/api/buffer.md
Expand Up @@ -1416,6 +1416,8 @@ changes:
Reads an unsigned, big-endian 64-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readBigUint64BE` alias.

```js
const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);

Expand Down Expand Up @@ -1443,6 +1445,8 @@ changes:
Reads an unsigned, little-endian 64-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readBigUint64LE` alias.

```js
const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);

Expand Down Expand Up @@ -1758,6 +1762,8 @@ changes:

Reads an unsigned 8-bit integer from `buf` at the specified `offset`.

This function is also available under the `readUint8` alias.

```js
const buf = Buffer.from([1, -2]);

Expand Down Expand Up @@ -1789,6 +1795,8 @@ changes:
Reads an unsigned, big-endian 16-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readUint16BE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56]);

Expand Down Expand Up @@ -1818,6 +1826,8 @@ changes:
Reads an unsigned, little-endian 16-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readUint16LE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56]);

Expand Down Expand Up @@ -1849,6 +1859,8 @@ changes:
Reads an unsigned, big-endian 32-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readUint32BE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);

Expand Down Expand Up @@ -1876,6 +1888,8 @@ changes:
Reads an unsigned, little-endian 32-bit integer from `buf` at the specified
`offset`.

This function is also available under the `readUint32LE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);

Expand Down Expand Up @@ -1908,6 +1922,8 @@ Reads `byteLength` number of bytes from `buf` at the specified `offset`
and interprets the result as an unsigned big-endian integer supporting
up to 48 bits of accuracy.

This function is also available under the `readUintBE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);

Expand Down Expand Up @@ -1940,6 +1956,8 @@ Reads `byteLength` number of bytes from `buf` at the specified `offset`
and interprets the result as an unsigned, little-endian integer supporting
up to 48 bits of accuracy.

This function is also available under the `readUintLE` alias.

```js
const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);

Expand Down Expand Up @@ -2353,6 +2371,8 @@ changes:

Writes `value` to `buf` at the specified `offset` as big-endian.

This function is also available under the `writeBigUint64BE` alias.

```js
const buf = Buffer.allocUnsafe(8);

Expand Down Expand Up @@ -2389,6 +2409,8 @@ console.log(buf);
// Prints: <Buffer de fa ce ca fe fa ca de>
```

This function is also available under the `writeBigUint64LE` alias.

### `buf.writeDoubleBE(value[, offset])`
<!-- YAML
added: v0.11.15
Expand Down Expand Up @@ -2734,6 +2756,8 @@ Writes `value` to `buf` at the specified `offset`. `value` must be a
valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
other than an unsigned 8-bit integer.

This function is also available under the `writeUint8` alias.

```js
const buf = Buffer.allocUnsafe(4);

Expand Down Expand Up @@ -2768,6 +2792,8 @@ Writes `value` to `buf` at the specified `offset` as big-endian. The `value`
must be a valid unsigned 16-bit integer. Behavior is undefined when `value`
is anything other than an unsigned 16-bit integer.

This function is also available under the `writeUint16BE` alias.

```js
const buf = Buffer.allocUnsafe(4);

Expand Down Expand Up @@ -2802,6 +2828,8 @@ Writes `value` to `buf` at the specified `offset` as little-endian. The `value`
must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
anything other than an unsigned 16-bit integer.

This function is also available under the `writeUint16LE` alias.

```js
const buf = Buffer.allocUnsafe(4);

Expand Down Expand Up @@ -2834,6 +2862,8 @@ Writes `value` to `buf` at the specified `offset` as big-endian. The `value`
must be a valid unsigned 32-bit integer. Behavior is undefined when `value`
is anything other than an unsigned 32-bit integer.

This function is also available under the `writeUint32BE` alias.

```js
const buf = Buffer.allocUnsafe(4);

Expand Down Expand Up @@ -2865,6 +2895,8 @@ Writes `value` to `buf` at the specified `offset` as little-endian. The `value`
must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
anything other than an unsigned 32-bit integer.

This function is also available under the `writeUint32LE` alias.

```js
const buf = Buffer.allocUnsafe(4);

Expand Down Expand Up @@ -2898,6 +2930,8 @@ Writes `byteLength` bytes of `value` to `buf` at the specified `offset`
as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
when `value` is anything other than an unsigned integer.

This function is also available under the `writeUintBE` alias.

```js
const buf = Buffer.allocUnsafe(6);

Expand Down Expand Up @@ -2931,6 +2965,8 @@ Writes `byteLength` bytes of `value` to `buf` at the specified `offset`
as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
when `value` is anything other than an unsigned integer.

This function is also available under the `writeUintLE` alias.

```js
const buf = Buffer.allocUnsafe(6);

Expand Down

0 comments on commit cf0fa7f

Please sign in to comment.