@@ -53,14 +53,14 @@ const extensionCodec = new ExtensionCodec();
5353// Set<T>
5454extensionCodec .register ({
5555 type: 0 ,
56- encode : (object : unknown ) => {
56+ encode : (object : unknown ): Uint8Array | null => {
5757 if (object instanceof Set ) {
5858 return encode ([... object ]);
5959 } else {
6060 return null ;
6161 }
6262 },
63- decode : (data ) => {
63+ decode : (data : Uint8Array ) => {
6464 const array = decode (data ) as Array <any >;
6565 return new Set (array );
6666 },
@@ -69,14 +69,14 @@ extensionCodec.register({
6969// Map<T>
7070extensionCodec .register ({
7171 type: 1 ,
72- encode : (object : unknown ) => {
72+ encode : (object : unknown ): Uint8Array => {
7373 if (object instanceof Map ) {
7474 return encode ([... object ]);
7575 } else {
7676 return null ;
7777 }
7878 },
79- decode : (data ) => {
79+ decode : (data : Uint8Array ) => {
8080 const array = decode (data ) as Array <[unknown , unknown ]>;
8181 return new Map (array );
8282 },
@@ -91,6 +91,18 @@ const decoded = decode(encoded, { extensionCodec });
9191
9292Not that extension types for custom objects must be ` [0, 127] ` , while ` [-1, -128] ` is reserved to MessagePack itself.
9393
94+ ## Prerequsites
95+
96+ * ES5 language features
97+ * Typed Arrays (ES2015; [ Can I use Typed Arrays?] ( https://caniuse.com/#feat=typedarrays ) )
98+ * String.prototype.padStart (ES2017; [ caniuse] ( https://caniuse.com/#feat=pad-start-end ) )
99+
100+ You can use polyfills for them.
101+
102+ ### NodeJS
103+
104+ If you use this library in NodeJS, v10 or later is required.
105+
94106## Distrubition
95107
96108The NPM package distributed in npmjs.com includes both ES2015+ and ES5 files:
0 commit comments