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 f60ce10

Browse filesBrowse files
jasnellMyles Borins
authored andcommitted
doc: document unspecified behavior for buf.write* methods
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>
1 parent 132acea commit f60ce10
Copy full SHA for f60ce10

File tree

Expand file treeCollapse file tree

1 file changed

+21
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-10
lines changed
Open diff view settings
Collapse file

‎doc/api/buffer.markdown‎

Copy file name to clipboardExpand all lines: doc/api/buffer.markdown
+21-10Lines changed: 21 additions & 10 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,8 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
10331033

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

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

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

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

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

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

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

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

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

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

1203+
Behavior is not defined when `value` is anything other than an integer.
1204+
11991205
### buf.writeUInt8(value, offset[, noAssert])
12001206

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

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

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

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

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

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

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

1326+
Behavior is not defined when `value` is anything other than an unsigned integer.
1327+
13171328
## buffer.INSPECT_MAX_BYTES
13181329

13191330
* {Number} Default: 50

0 commit comments

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