|
4 | 4 | // Serializes a value to a MessagePack byte array.
|
5 | 5 | //
|
6 | 6 | // data: The value to serialize. This can be a scalar, array or object.
|
7 |
| - // options: An object that defined additional options. |
8 |
| - // - multiple: Indicates whether multiple values in data are concatenated to multiple MessagePack arrays. |
9 |
| - // - invalidTypeReplacement: The value that is used to replace values of unsupported types, or a function that returns such a value, given the original value as parameter. |
| 7 | + // options: An object that defines additional options. |
| 8 | + // - multiple: (boolean) Indicates whether multiple values in data are concatenated to multiple MessagePack arrays. Default: false. |
| 9 | + // - invalidTypeReplacement: |
| 10 | + // (any) The value that is used to replace values of unsupported types. |
| 11 | + // (function) A function that returns such a value, given the original value as parameter. |
10 | 12 | function serialize(data, options) {
|
11 | 13 | if (options && options.multiple && !Array.isArray(data)) {
|
12 | 14 | throw new Error("Invalid argument type: Expected an Array to serialize multiple values.");
|
|
267 | 269 | // Deserializes a MessagePack byte array to a value.
|
268 | 270 | //
|
269 | 271 | // array: The MessagePack byte array to deserialize. This must be an Array or Uint8Array containing bytes, not a string.
|
270 |
| - // options: An object that defined additional options. |
271 |
| - // - multiple: Indicates whether multiple concatenated MessagePack arrays are returned as an array. |
| 272 | + // options: An object that defines additional options. |
| 273 | + // - multiple: (boolean) Indicates whether multiple concatenated MessagePack arrays are returned as an array. Default: false. |
272 | 274 | function deserialize(array, options) {
|
273 | 275 | const pow32 = 0x100000000; // 2^32
|
274 | 276 | let pos = 0;
|
|
0 commit comments