@@ -28,41 +28,4 @@ describe("README", () => {
2828 deepStrictEqual ( decode ( encoded ) , object ) ;
2929 } ) ;
3030 } ) ;
31-
32- context ( "timestamp/temporal" , ( ) => {
33- before ( function ( ) {
34- if ( typeof BigInt === "undefined" ) {
35- this . skip ( ) ;
36- }
37- } ) ;
38-
39- it ( "overrides timestamp-ext with std-temporal" , ( ) => {
40- const Instant = require ( "@std-proposal/temporal" ) . Instant ;
41-
42- const extensionCodec = new ExtensionCodec ( ) ;
43- extensionCodec . register ( {
44- type : EXT_TIMESTAMP ,
45- encode : ( input : any ) => {
46- if ( input instanceof Instant ) {
47- const sec = input . seconds ;
48- const nsec = Number ( input . nanoseconds - BigInt ( sec ) * BigInt ( 1e9 ) ) ;
49- return encodeTimeSpecToTimestamp ( { sec, nsec } ) ;
50- } else {
51- return null ;
52- }
53- } ,
54- decode : ( data : Uint8Array ) => {
55- const timeSpec = decodeTimestampToTimeSpec ( data ) ;
56- const sec = BigInt ( timeSpec . sec ) ;
57- const nsec = BigInt ( timeSpec . nsec ) ;
58- return Instant . fromEpochNanoseconds ( sec * BigInt ( 1e9 ) + nsec ) ;
59- } ,
60- } ) ;
61-
62- const instant = Instant . fromEpochMilliseconds ( Date . now ( ) ) ;
63- const encoded = encode ( instant , { extensionCodec } ) ;
64- const decoded = decode ( encoded , { extensionCodec } ) ;
65- deepStrictEqual ( decoded , instant ) ;
66- } ) ;
67- } ) ;
6831} ) ;
0 commit comments