Skip to content

Commit

Permalink
doc: document unspecified behavior for buf.write* methods
Browse files Browse the repository at this point in the history
Per #1161, when the
buf.write*() methods are given anything other than what
they expect, indicate that the behavior is unspecified.

Fixes: #1161
PR-URL: #5925
Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com>
  • Loading branch information
jasnell authored and Myles Borins committed Apr 11, 2016
1 parent 132acea commit f60ce10
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions doc/api/buffer.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,8 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeDoubleBE()` writes big endian, `writeDoubleLE()` writes little
endian). The `value` argument must be a valid 64-bit double.
endian). The `value` argument *should* be a valid 64-bit double. Behavior is
not defined when `value` is anything other than a 64-bit double.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand Down Expand Up @@ -1065,7 +1066,7 @@ console.log(buf);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeFloatBE()` writes big endian, `writeFloatLE()` writes little
endian). Behavior is unspecified if `value` is anything other than a 32-bit
endian). Behavior is not defined when `value` is anything other than a 32-bit
float.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
Expand Down Expand Up @@ -1095,8 +1096,9 @@ console.log(buf);
* `noAssert` {Boolean} Default: false
* Return: {Number} The offset plus the number of written bytes

Writes `value` to the Buffer at the specified `offset`. The `value` must be a
valid signed 8-bit integer.
Writes `value` to the Buffer at the specified `offset`. The `value` should be a
valid signed 8-bit integer. Behavior is not defined when `value` is anything
other than a signed 8-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand All @@ -1123,7 +1125,8 @@ console.log(buf);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeInt16BE()` writes big endian, `writeInt16LE()` writes little
endian). The `value` must be a valid signed 16-bit integer.
endian). The `value` should be a valid signed 16-bit integer. Behavior is
not defined when `value` is anything other than a signed 16-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand All @@ -1150,7 +1153,8 @@ console.log(buf);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeInt32BE()` writes big endian, `writeInt32LE()` writes little
endian). The `value` must be a valid signed 32-bit integer.
endian). The `value` should be a valid signed 32-bit integer. Behavior is
not defined when `value` is anything other than a signed 32-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand Down Expand Up @@ -1196,15 +1200,18 @@ that `value` may be too large for the specific function and `offset` may be
beyond the end of the Buffer leading to the values being silently dropped. This
should not be used unless you are certain of correctness.

Behavior is not defined when `value` is anything other than an integer.

### buf.writeUInt8(value, offset[, noAssert])

* `value` {Number} Bytes to be written to Buffer
* `offset` {Number} `0 <= offset <= buf.length - 1`
* `noAssert` {Boolean} Default: false
* Return: {Number} The offset plus the number of written bytes

Writes `value` to the Buffer at the specified `offset`. The `value` must be a
valid unsigned 8-bit integer.
Writes `value` to the Buffer at the specified `offset`. The `value` should be a
valid unsigned 8-bit integer. Behavior is not defined when `value` is anything
other than an unsigned 8-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand Down Expand Up @@ -1234,7 +1241,8 @@ console.log(buf);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeUInt16BE()` writes big endian, `writeUInt16LE()` writes little
endian). The `value` must be a valid unsigned 16-bit integer.
endian). The `value` should be a valid unsigned 16-bit integer. Behavior is
not defined when `value` is anything other than an unsigned 16-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand Down Expand Up @@ -1268,7 +1276,8 @@ console.log(buf);

Writes `value` to the Buffer at the specified `offset` with specified endian
format (`writeUInt32BE()` writes big endian, `writeUInt32LE()` writes little
endian). The `value` must be a valid unsigned 32-bit integer.
endian). The `value` should be a valid unsigned 32-bit integer. Behavior is
not defined when `value` is anything other than an unsigned 32-bit integer.

Set `noAssert` to true to skip validation of `value` and `offset`. This means
that `value` may be too large for the specific function and `offset` may be
Expand Down Expand Up @@ -1314,6 +1323,8 @@ that `value` may be too large for the specific function and `offset` may be
beyond the end of the Buffer leading to the values being silently dropped. This
should not be used unless you are certain of correctness.

Behavior is not defined when `value` is anything other than an unsigned integer.

## buffer.INSPECT_MAX_BYTES

* {Number} Default: 50
Expand Down

0 comments on commit f60ce10

Please sign in to comment.