@@ -337,7 +337,7 @@ extensionCodec.register({
337
337
type: MYTYPE_EXT_TYPE ,
338
338
encode : (object , context ) => {
339
339
if (object instanceof MyType ) {
340
- context .track (object ); // <-- like this
340
+ context .track (object );
341
341
return encode (object .toJSON (), { extensionCodec , context });
342
342
} else {
343
343
return null ;
@@ -346,7 +346,7 @@ extensionCodec.register({
346
346
decode : (data , extType , context ) => {
347
347
const decoded = decode (data , { extensionCodec , context });
348
348
const my = new MyType (decoded );
349
- context .track (my ); // <-- and like this
349
+ context .track (my );
350
350
return my ;
351
351
},
352
352
});
@@ -356,7 +356,7 @@ import { encode, decode } from "@msgpack/msgpack";
356
356
357
357
const context = new MyContext ();
358
358
359
- const encoded = = encode ({myType: new MyType <any >()}, { extensionCodec , context });
359
+ const encoded = encode ({ myType: new MyType <any >() }, { extensionCodec , context });
360
360
const decoded = decode (encoded , { extensionCodec , context });
361
361
```
362
362
@@ -376,7 +376,7 @@ So you might want to define a custom codec to handle bigint like this:
376
376
377
377
``` typescript
378
378
import { deepStrictEqual } from " assert" ;
379
- import { encode , decode , ExtensionCodec } from " @msgpack/msgpack" ;
379
+ import { encode , decode , ExtensionCodec , DecodeError } from " @msgpack/msgpack" ;
380
380
381
381
// to define a custom codec:
382
382
const BIGINT_EXT_TYPE = 0 ; // Any in 0-127
@@ -405,7 +405,7 @@ extensionCodec.register({
405
405
406
406
// to use it:
407
407
const value = BigInt (Number .MAX_SAFE_INTEGER) + BigInt (1 );
408
- const encoded: = encode (value , { extensionCodec });
408
+ const encoded = encode (value , { extensionCodec });
409
409
deepStrictEqual (decode (encoded , { extensionCodec }), value );
410
410
```
411
411
0 commit comments