Skip to content

Commit c22cbc9

Browse files
authored
[doc] Revise WebSocket#send() docs for clarity (#2077)
Add reference to Node.js's own related documentation about the constraints on `Object` values. Fixes #2076
1 parent 9753821 commit c22cbc9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doc/ws.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,9 @@ only removes listeners added with
554554
### websocket.send(data[, options][, callback])
555555

556556
- `data` {Array|Number|Object|String|ArrayBuffer|Buffer|DataView|TypedArray} The
557-
data to send.
557+
data to send. `Object` values are only supported if they conform to the
558+
requirements of [`Buffer.from()`][]. If those constraints are not met, a
559+
`TypeError` is thrown.
558560
- `options` {Object}
559561
- `binary` {Boolean} Specifies whether `data` should be sent as a binary or
560562
not. Default is autodetected.
@@ -656,6 +658,8 @@ as configured by the `maxPayload` option.
656658
[concurrency-limit]: https://github.com/websockets/ws/issues/1202
657659
[duplex-options]:
658660
https://nodejs.org/api/stream.html#stream_new_stream_duplex_options
661+
[`buffer.from()`]:
662+
https://nodejs.org/api/buffer.html#static-method-bufferfromobject-offsetorencoding-length
659663
[`http.request()`]:
660664
https://nodejs.org/api/http.html#http_http_request_options_callback
661665
[`https.request()`]:

0 commit comments

Comments
 (0)