@@ -337,7 +337,7 @@ extensionCodec.register({
337337 type: MYTYPE_EXT_TYPE ,
338338 encode : (object , context ) => {
339339 if (object instanceof MyType ) {
340- context .track (object ); // <-- like this
340+ context .track (object );
341341 return encode (object .toJSON (), { extensionCodec , context });
342342 } else {
343343 return null ;
@@ -346,7 +346,7 @@ extensionCodec.register({
346346 decode : (data , extType , context ) => {
347347 const decoded = decode (data , { extensionCodec , context });
348348 const my = new MyType (decoded );
349- context .track (my ); // <-- and like this
349+ context .track (my );
350350 return my ;
351351 },
352352});
@@ -356,7 +356,7 @@ import { encode, decode } from "@msgpack/msgpack";
356356
357357const context = new MyContext ();
358358
359- const encoded = = encode ({myType: new MyType <any >()}, { extensionCodec , context });
359+ const encoded = encode ({ myType: new MyType <any >() }, { extensionCodec , context });
360360const decoded = decode (encoded , { extensionCodec , context });
361361```
362362
@@ -376,7 +376,7 @@ So you might want to define a custom codec to handle bigint like this:
376376
377377``` typescript
378378import { deepStrictEqual } from " assert" ;
379- import { encode , decode , ExtensionCodec } from " @msgpack/msgpack" ;
379+ import { encode , decode , ExtensionCodec , DecodeError } from " @msgpack/msgpack" ;
380380
381381// to define a custom codec:
382382const BIGINT_EXT_TYPE = 0 ; // Any in 0-127
@@ -405,7 +405,7 @@ extensionCodec.register({
405405
406406// to use it:
407407const value = BigInt (Number .MAX_SAFE_INTEGER) + BigInt (1 );
408- const encoded: = encode (value , { extensionCodec });
408+ const encoded = encode (value , { extensionCodec });
409409deepStrictEqual (decode (encoded , { extensionCodec }), value );
410410```
411411
0 commit comments