Skip to content

Commit 8cafd86

Browse files
committed
readme
1 parent 9f5cd98 commit 8cafd86

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

README.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This library serves as a comprehensive reference implementation of MessagePack f
1010

1111
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`).
1212

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).
1414

1515
## Synopsis
1616

@@ -466,44 +466,66 @@ Note that as of June 2019 there're no official "version" on the MessagePack spec
466466

467467
The following table shows how JavaScript values are mapped to [MessagePack formats](https://github.com/msgpack/msgpack/blob/master/spec.md) and vice versa.
468468

469+
The mapping of integers varies on the setting of `useBigInt64`.
470+
471+
The default, `useBigInt64: false` is:
472+
469473
Source Value|MessagePack Format|Value Decoded
470474
----|----|----
471475
null, undefined|nil|null (*1)
472476
boolean (true, false)|bool family|boolean (true, false)
473-
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
475479
string|str family|string
476480
ArrayBufferView |bin family|Uint8Array (*2)
477481
Array|array family|Array
478482
Object|map family|Object (*3)
479483
Date|timestamp ext family|Date (*4)
484+
bigint|N/A|N/A (*5)
480485

481486
* *1 Both `null` and `undefined` are mapped to `nil` (`0xC0`) type, and are decoded into `null`
482487
* *2 Any `ArrayBufferView`s including NodeJS's `Buffer` are mapped to `bin` family, and are decoded into `Uint8Array`
483488
* *3 In handling `Object`, it is regarded as `Record<string, unknown>` in terms of TypeScript
484489
* *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:
493+
494+
Source Value|MessagePack Format|Value Decoded
495+
----|----|----
496+
null, undefined|nil|null
497+
boolean (true, false)|bool family|boolean (true, false)
498+
**number (32-bit int)**|int family|number
499+
**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.
485509

486510
## Prerequisites
487511

488512
This is a universal JavaScript library that supports major browsers and NodeJS.
489513

490514
### ECMA-262
491515

492-
* ES5 language features
516+
* ES2015 language features
493517
* ES2018 standard library, including:
494518
* Typed arrays (ES2015)
495519
* Async iterations (ES2018)
496-
* Features added in ES2015-ES2018
520+
* Features added in ES2015-ES2022
497521

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).
499523

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.
501525

502526
### NodeJS
503527

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`.
528+
NodeJS v14 is required.
507529

508530
### TypeScript Compiler / Type Definitions
509531

0 commit comments

Comments
 (0)