1- const { readFileSync } = require ( 'fs' ) ;
2- const { join } = require ( 'path' ) ;
1+ import { on } from 'node:events' ;
2+ import { readFileSync } from 'node:fs' ;
3+ import { join } from 'node:path' ;
34
4- const pako = require ( 'pako' ) ;
5- const { decode } = require ( 'uint8-base64' ) ;
5+ import pako from 'pako' ;
6+ import { decode } from 'uint8-base64' ;
67
7- const data = readFileSync ( join ( __dirname , 'big.xml' ) ) ;
8- const { parse } = require ( '../lib/index.js' ) ;
8+ import { parse } from '../lib/index.js' ;
99
10+ const data = readFileSync ( join ( import . meta. dirname , 'big.xml' ) ) ;
1011const decoder = new TextDecoder ( ) ;
1112
1213console . time ( 'start' ) ;
@@ -16,16 +17,13 @@ const result = parse(data, {
1617 dynamicTypingNodeValue : false ,
1718 tagValueProcessor : ( value , node ) => {
1819 if ( node . tagName !== 'binary' ) return decoder . decode ( value ) ;
19- if ( ! node . parent . children ) {
20- console . log ( node ) ;
21- }
2220 const ontologies = node . parent . children . cvParam . map (
2321 ( entry ) => entry . attributes . accession ,
2422 ) ;
2523 try {
26- return decodeBase64 ( node . value , { ontologies } ) ;
27- } catch ( e ) {
28- console . log ( node ) ;
24+ return decodeBase64 ( node . bytes , { ontologies } ) ;
25+ } catch ( error ) {
26+ console . log ( error ) ;
2927 }
3028 } ,
3129} ) ;
0 commit comments