File tree 3 files changed +39
-0
lines changed
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ // To execute ECMAScript Module import/export standards, the file convention should be .mjs instead of .js
2
+ // & it should be explicitly runned as > node httpsECMA.mjs
3
+
4
+ import { send , REQUEST_TIMEOUT } from "./requestECMA.mjs" ;
5
+ import { read } from "./responseECMA.mjs" ;
6
+
7
+ function makeRequest ( url , data ) {
8
+ send ( url , data ) ;
9
+ return read ( ) ;
10
+ }
11
+
12
+ const responseData = makeRequest ( "https:www.google.com" , "Hello" ) ;
13
+
14
+ setTimeout ( ( ) => {
15
+ console . log ( responseData ) ;
16
+ } , REQUEST_TIMEOUT ) ;
Original file line number Diff line number Diff line change
1
+ const REQUEST_TIMEOUT = 500 ;
2
+
3
+ function encrypt ( data ) {
4
+ return "encrypted data" ;
5
+ }
6
+
7
+ function send ( url , data ) {
8
+ const encryptedData = encrypt ( data ) ;
9
+ console . log ( `Sending ${ encryptedData } to ${ url } ` ) ;
10
+ }
11
+
12
+ // ECMAScript module standards
13
+ export { send , REQUEST_TIMEOUT } ;
Original file line number Diff line number Diff line change
1
+ function decrypt ( data ) {
2
+ return "decrypted data" ;
3
+ }
4
+
5
+ function read ( ) {
6
+ return decrypt ( "data" ) ;
7
+ }
8
+
9
+ // ECMAScript module standards
10
+ export { read } ;
You can’t perform that action at this time.
0 commit comments