You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-10Lines changed: 32 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ This library serves as a comprehensive reference implementation of MessagePack f
10
10
11
11
Additionally, this is also a universal JavaScript library. It is compatible not only with browsers, but with Node.js or other JavaScript engines that implement ES2015+ standards. As it is written in [TypeScript](https://www.typescriptlang.org/), this library bundles up-to-date type definition files (`d.ts`).
12
12
13
-
*Note that this is the second version of MessagePack for JavaScript. The first version, which was implemented in ES5 and was never released to npmjs.com, is tagged as [classic](https://github.com/msgpack/msgpack-javascript/tree/classic).*
13
+
*Note that this is the second edition of "MessagePack for JavaScript". The first edition, which was implemented in ES5 and never released to npmjs.com, is tagged as [`classic`](https://github.com/msgpack/msgpack-javascript/tree/classic).
14
14
15
15
## Synopsis
16
16
@@ -466,44 +466,66 @@ Note that as of June 2019 there're no official "version" on the MessagePack spec
466
466
467
467
The following table shows how JavaScript values are mapped to [MessagePack formats](https://github.com/msgpack/msgpack/blob/master/spec.md) and vice versa.
468
468
469
+
The mapping of integers varies on the setting of `useBigInt64`.
number (53-bit int)|int family|number (53-bit int)
474
-
number (64-bit float)|float family|number (64-bit float)
477
+
number (53-bit int)|int family|number
478
+
number (64-bit float)|float family|number
475
479
string|str family|string
476
480
ArrayBufferView |bin family|Uint8Array (*2)
477
481
Array|array family|Array
478
482
Object|map family|Object (*3)
479
483
Date|timestamp ext family|Date (*4)
484
+
bigint|N/A|N/A (*5)
480
485
481
486
**1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
482
487
**2 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
483
488
**3 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
484
489
**4 MessagePack timestamps may have nanoseconds, which will lost when it is decoded into JavaScript `Date`. This behavior can be overridden by registering `-1` for the extension codec.
490
+
**5 bigint is not supported in `useBigInt64: false` mode, but you can define an extension codec for it.
491
+
492
+
If you set `useBigInt64: true`, the following mapping is used:
**number (except for the above)**|float family|number
500
+
**bigint**|int64 / uint64|bigint (*6)
501
+
string|str family|string
502
+
ArrayBufferView |bin family|Uint8Array
503
+
Array|array family|Array
504
+
Object|map family|Object
505
+
Date|timestamp ext family|Date
506
+
507
+
508
+
**6 If the bigint is larger than the max value of uint64 or smaller than the min value of int64, then the behavior is undefined.
485
509
486
510
## Prerequisites
487
511
488
512
This is a universal JavaScript library that supports major browsers and NodeJS.
489
513
490
514
### ECMA-262
491
515
492
-
*ES5 language features
516
+
*ES2015 language features
493
517
* ES2018 standard library, including:
494
518
* Typed arrays (ES2015)
495
519
* Async iterations (ES2018)
496
-
* Features added in ES2015-ES2018
520
+
* Features added in ES2015-ES2022
497
521
498
-
ES2018 standard library used in this library can be polyfilled with [core-js](https://github.com/zloirock/core-js).
522
+
ES2022 standard library used in this library can be polyfilled with [core-js](https://github.com/zloirock/core-js).
499
523
500
-
If you support IE11, import `core-js` in your application entrypoints, as this library does in testing for browsers.
524
+
IE11 is no longer supported. If you'd like to use this library in IE11, use v2.x versions.
501
525
502
526
### NodeJS
503
527
504
-
NodeJS v10 is required, but NodeJS v12 or later is recommended because it includes the V8 feature of [Improving DataView performance in V8](https://v8.dev/blog/dataview).
505
-
506
-
NodeJS before v10 will work by importing `@msgpack/msgpack/dist.es5+umd/msgpack`.
0 commit comments