44// University of Illinois/NCSA Open Source License. Both these licenses can be
55// found in the LICENSE file.
66
7- 'use strict' ;
8-
9- const fs = require ( 'fs' ) ;
10- const path = require ( 'path' ) ;
11-
12- const arguments_ = process . argv . slice ( 2 ) ;
13- const debug = false ;
7+ import * as fs from 'fs' ;
8+ import * as path from 'path' ;
149
1510function print ( x ) {
1611 process . stdout . write ( x + '\n' ) ;
@@ -20,38 +15,24 @@ function printErr(x) {
2015 process . stderr . write ( x + '\n' ) ;
2116}
2217
23- function read ( filename , binary ) {
24- filename = path . normalize ( filename ) ;
25- let ret = fs . readFileSync ( filename ) ;
26- if ( ret && ! binary ) ret = ret . toString ( ) ;
27- return ret ;
28- }
29-
30- function readBinary ( filename ) {
31- return read ( filename , true ) ;
32- }
33-
34- function globalEval ( x ) {
35- eval . call ( null , x ) ;
36- }
37-
38- function load ( f ) {
39- globalEval ( read ( f ) ) ;
40- }
41-
42- global . assert = ( x , message ) => {
18+ globalThis . assert = ( x , message ) => {
4319 if ( ! x ) throw new Error ( message ) ;
4420} ;
4521
4622// Redirect console.log message from MiniLZ4 to stderr since stdout is
4723// where we return the decompressed data.
4824console . log = printErr ;
4925
50- const lz4 = arguments_ [ 0 ] ;
51- const input = arguments_ [ 1 ] ;
52- const output = arguments_ [ 2 ] ;
26+ const MiniLZ4 = await import ( '../third_party/mini-lz4.js' ) ;
5327
54- load ( lz4 ) ;
28+ function readBinary ( filename ) {
29+ filename = path . normalize ( filename ) ;
30+ return fs . readFileSync ( filename ) ;
31+ }
32+
33+ const arguments_ = process . argv . slice ( 2 ) ;
34+ const input = arguments_ [ 0 ] ;
35+ const output = arguments_ [ 1 ] ;
5536
5637const data = new Uint8Array ( readBinary ( input ) ) . buffer ;
5738const start = Date . now ( ) ;
0 commit comments