@@ -37,7 +37,7 @@ import binaryen from "../lib/binaryen.js";
3737import * as assemblyscriptJS from "assemblyscript" ;
3838
3939// Use the TS->JS variant by default
40- var assemblyscript = assemblyscriptJS ;
40+ let assemblyscript = assemblyscriptJS ;
4141
4242// Use the AS->Wasm variant as an option (experimental)
4343const wasmPos = process . argv . indexOf ( "--wasm" ) ;
@@ -115,7 +115,7 @@ export function configToArguments(options, argv = []) {
115115/** Convenience function that parses and compiles source strings directly. */
116116export async function compileString ( sources , config = { } ) {
117117 if ( typeof sources === "string" ) sources = { [ `input${ extension } ` ] : sources } ;
118- var argv = [
118+ let argv = [
119119 "--outFile" , "binary" ,
120120 "--textFile" , "text" ,
121121 ] ;
@@ -182,11 +182,11 @@ export async function main(argv, options) {
182182 ) ;
183183 }
184184
185- var module = null ;
186- var binaryenModule = null ;
185+ let module = null ;
186+ let binaryenModule = null ;
187187
188188 // Prepares the result object
189- var prepareResult = ( error , result = { } ) => {
189+ let prepareResult = ( error , result = { } ) => {
190190 if ( error ) {
191191 stderr . write ( `${ stderrColors . red ( "FAILURE " ) } ${ error . stack . replace ( / ^ E R R O R : / i, "" ) } ${ EOL } ` ) ;
192192 }
@@ -213,8 +213,8 @@ export async function main(argv, options) {
213213
214214 // Print the help message if requested or no source files are provided
215215 if ( opts . help || ( ! argv . length && ! configHasEntries ) ) {
216- var out = opts . help ? stdout : stderr ;
217- var colors = opts . help ? stdoutColors : stderrColors ;
216+ let out = opts . help ? stdout : stderr ;
217+ let colors = opts . help ? stdoutColors : stderrColors ;
218218 out . write ( [
219219 colors . white ( "SYNTAX" ) ,
220220 " " + colors . cyan ( "asc" ) + " [entryFile ...] [options]" ,
@@ -295,7 +295,7 @@ export async function main(argv, options) {
295295 }
296296
297297 // Set up options
298- var program , runtime ;
298+ let program , runtime ;
299299 const compilerOptions = assemblyscript . newOptions ( ) ;
300300 switch ( opts . runtime ) {
301301 case "stub" : runtime = 0 ; break ;
@@ -358,7 +358,7 @@ export async function main(argv, options) {
358358 }
359359
360360 // Disable default features if specified
361- var features ;
361+ let features ;
362362 if ( ( features = opts . disable ) != null ) {
363363 if ( typeof features === "string" ) features = features . split ( "," ) ;
364364 for ( let i = 0 , k = features . length ; i < k ; ++ i ) {
@@ -381,8 +381,8 @@ export async function main(argv, options) {
381381 }
382382
383383 // Set up optimization levels
384- var optimizeLevel = 0 ;
385- var shrinkLevel = 0 ;
384+ let optimizeLevel = 0 ;
385+ let shrinkLevel = 0 ;
386386 if ( opts . optimize ) {
387387 optimizeLevel = defaultOptimizeLevel ;
388388 shrinkLevel = defaultShrinkLevel ;
@@ -518,8 +518,8 @@ export async function main(argv, options) {
518518
519519 // Gets the file matching the specified source path, imported at the given dependee path
520520 async function getFile ( internalPath , dependeePath ) {
521- var sourceText = null ; // text reported back to the compiler
522- var sourcePath = null ; // path reported back to the compiler
521+ let sourceText = null ; // text reported back to the compiler
522+ let sourcePath = null ; // path reported back to the compiler
523523
524524 // Try file.ext, file/index.ext, file.d.ext
525525 if ( ! internalPath . startsWith ( libraryPrefix ) ) {
@@ -602,7 +602,7 @@ export async function main(argv, options) {
602602
603603 // Parses the backlog of imported files after including entry files
604604 async function parseBacklog ( ) {
605- var backlog ;
605+ let backlog ;
606606 while ( ( backlog = getBacklog ( ) ) . length ) {
607607 let files = [ ] ;
608608 for ( let internalPath of backlog ) {
@@ -733,7 +733,7 @@ export async function main(argv, options) {
733733 ? assemblyscript . getBinaryenModuleRef ( module )
734734 : module . ref
735735 ) ;
736- var numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
736+ let numErrors = checkDiagnostics ( program , stderr , opts . disableWarning , options . reportDiagnostic , stderrColors . enabled ) ;
737737 if ( numErrors ) {
738738 const err = Error ( `${ numErrors } compile error(s)` ) ;
739739 err . stack = err . message ; // omit stack
@@ -1132,7 +1132,7 @@ async function getConfig(file, baseDir, readFile) {
11321132/** Checks diagnostics emitted so far for errors. */
11331133export function checkDiagnostics ( program , stderr , disableWarning , reportDiagnostic , useColors ) {
11341134 if ( typeof useColors === "undefined" && stderr ) useColors = stderr . isTTY ;
1135- var numErrors = 0 ;
1135+ let numErrors = 0 ;
11361136 do {
11371137 let diagnostic = assemblyscript . nextDiagnostic ( program ) ;
11381138 if ( ! diagnostic ) break ;
@@ -1224,13 +1224,13 @@ export class Stats {
12241224 }
12251225}
12261226
1227- var allocBuffer = typeof global !== "undefined" && global . Buffer
1227+ let allocBuffer = typeof global !== "undefined" && global . Buffer
12281228 ? global . Buffer . allocUnsafe || ( len => new global . Buffer ( len ) )
12291229 : len => new Uint8Array ( len ) ;
12301230
12311231/** Creates a memory stream that can be used in place of stdout/stderr. */
12321232export function createMemoryStream ( fn ) {
1233- var stream = [ ] ;
1233+ let stream = [ ] ;
12341234 stream . write = function ( chunk ) {
12351235 if ( fn ) fn ( chunk ) ;
12361236 if ( typeof chunk === "string" ) {
@@ -1244,9 +1244,9 @@ export function createMemoryStream(fn) {
12441244 stream . length = 0 ;
12451245 } ;
12461246 stream . toBuffer = function ( ) {
1247- var offset = 0 , i = 0 , k = this . length ;
1247+ let offset = 0 , i = 0 , k = this . length ;
12481248 while ( i < k ) offset += this [ i ++ ] . length ;
1249- var buffer = allocBuffer ( offset ) ;
1249+ let buffer = allocBuffer ( offset ) ;
12501250 offset = i = 0 ;
12511251 while ( i < k ) {
12521252 buffer . set ( this [ i ] , offset ) ;
@@ -1256,7 +1256,7 @@ export function createMemoryStream(fn) {
12561256 return buffer ;
12571257 } ;
12581258 stream . toString = function ( ) {
1259- var buffer = this . toBuffer ( ) ;
1259+ let buffer = this . toBuffer ( ) ;
12601260 return utf8 . read ( buffer , 0 , buffer . length ) ;
12611261 } ;
12621262 return stream ;
0 commit comments