@@ -30,23 +30,33 @@ mergeInto(LibraryManager.library, {
30
30
31
31
mp_js_ticks_ms : ( ) => Date . now ( ) - MP_JS_EPOCH ,
32
32
33
- mp_js_hook : function ( ) {
33
+ mp_js_hook : ( ) => {
34
34
if ( ENVIRONMENT_IS_NODE ) {
35
- var mp_interrupt_char = Module . ccall ( 'mp_hal_get_interrupt_char' , 'number' , [ 'number' ] , [ 'null' ] ) ;
36
- var fs = require ( 'fs' ) ;
35
+ const mp_interrupt_char = Module . ccall (
36
+ "mp_hal_get_interrupt_char" ,
37
+ "number" ,
38
+ [ "number" ] ,
39
+ [ "null" ] ,
40
+ ) ;
41
+ const fs = require ( "fs" ) ;
37
42
38
- var buf = Buffer . alloc ( 1 ) ;
43
+ const buf = Buffer . alloc ( 1 ) ;
39
44
try {
40
- var n = fs . readSync ( process . stdin . fd , buf , 0 , 1 ) ;
45
+ const n = fs . readSync ( process . stdin . fd , buf , 0 , 1 ) ;
41
46
if ( n > 0 ) {
42
- if ( buf [ 0 ] == mp_interrupt_char ) {
43
- Module . ccall ( 'mp_sched_keyboard_interrupt' , 'null' , [ 'null' ] , [ 'null' ] ) ;
47
+ if ( buf [ 0 ] === mp_interrupt_char ) {
48
+ Module . ccall (
49
+ "mp_sched_keyboard_interrupt" ,
50
+ "null" ,
51
+ [ "null" ] ,
52
+ [ "null" ] ,
53
+ ) ;
44
54
} else {
45
55
process . stdout . write ( String . fromCharCode ( buf [ 0 ] ) ) ;
46
56
}
47
57
}
48
58
} catch ( e ) {
49
- if ( e . code === ' EAGAIN' ) {
59
+ if ( e . code === " EAGAIN" ) {
50
60
} else {
51
61
throw e ;
52
62
}
0 commit comments