Buffer implementation, in browsers use buffer
npm package
and import it from buffer/
, in Node.js simply pass Buffer
.
[customSerializers, options] - optional arguments if you need to serialize custom data types, see: serialize
Rest
...args: unknown[]any data to serialize, can be a Buffer, string or any other data type
Buffer - serialized data
Serialize any data to a Buffer, useful when working with web sockets or other binary protocols. Make sure to understand how serialize works before using this function.
To make this function work in browsers it accepts a BufferImplementation parameter. To make the serialization customizable it accepts a serializeArgs parameter. It's therefore recommended to first prepare the function with bind, like:
Example
Otherwise pass the params each time: