File tree Expand file tree Collapse file tree 2 files changed +8
-14
lines changed
Expand file tree Collapse file tree 2 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import {
1414 BsonTimestamp ,
1515} from '../bson/values' ;
1616import { Reader } from '@jsonjoy.com/util/lib/buffers/Reader' ;
17+ import { JsonDecoder } from '../json/JsonDecoder' ;
1718import { readKey } from '../json/JsonDecoder' ;
1819import type { BinaryJsonDecoder } from '../types' ;
1920
@@ -22,19 +23,9 @@ export interface EjsonDecoderOptions {
2223 legacy ?: boolean ;
2324}
2425
25- export class EjsonDecoder implements BinaryJsonDecoder {
26- public reader = new Reader ( ) ;
27-
28- constructor ( private options : EjsonDecoderOptions = { } ) { }
29-
30- public read ( uint8 : Uint8Array ) : unknown {
31- this . reader . reset ( uint8 ) ;
32- return this . readAny ( ) ;
33- }
34-
35- public decode ( uint8 : Uint8Array ) : unknown {
36- this . reader . reset ( uint8 ) ;
37- return this . readAny ( ) ;
26+ export class EjsonDecoder extends JsonDecoder {
27+ constructor ( private options : EjsonDecoderOptions = { } ) {
28+ super ( ) ;
3829 }
3930
4031 /**
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ export class EjsonEncoder extends JsonEncoder {
4141 return new TextDecoder ( ) . decode ( bytes ) ;
4242 }
4343
44+ public writeUnknown ( value : unknown ) : void {
45+ this . writeNull ( ) ;
46+ }
47+
4448 public writeAny ( value : unknown ) : void {
4549 if ( value === null || value === undefined ) {
4650 if ( value === undefined ) {
@@ -421,7 +425,6 @@ export class EjsonEncoder extends JsonEncoder {
421425 this . writeStr ( value . subtype . toString ( 16 ) . padStart ( 2 , '0' ) ) ;
422426 writer . u16 ( 0x7d7d ) ; // }}
423427 }
424- }
425428
426429 private writeBsonCodeAsEjson ( value : BsonJavascriptCode ) : void {
427430 // Write {"$code":"..."}
You can’t perform that action at this time.
0 commit comments