File tree 13 files changed +24
-10
lines changed
13 files changed +24
-10
lines changed File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const fs = require ( 'fs' ) ;
4
- const promisify = require ( './promisify ' ) ;
4
+ const { promisify } = require ( 'util ' ) ;
5
5
6
6
const readFile = promisify ( fs . readFile ) ;
7
7
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const fs = require ( 'fs' ) ;
4
- const promisify = require ( './promisify ' ) ;
4
+ const { promisify } = require ( 'util ' ) ;
5
5
6
6
const readFile = promisify ( fs . readFile ) ;
7
7
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const fs = require ( 'fs' ) ;
4
- const promisify = require ( './promisify ' ) ;
4
+ const { promisify } = require ( 'util ' ) ;
5
5
6
6
const readFile = promisify ( fs . readFile ) ;
7
7
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ httpGet(baseUrl).then((api) => {
11
11
}
12
12
Promise . all ( promises ) . then ( ( values ) => {
13
13
console . log ( values ) ;
14
- } ) ;
14
+ } ) . catch ( ) ;
15
15
} ) ;
Original file line number Diff line number Diff line change @@ -11,3 +11,5 @@ async(function* () {
11
11
console . log ( data ) ;
12
12
}
13
13
} ) ;
14
+
15
+
Original file line number Diff line number Diff line change 2
2
3
3
const fs = require ( 'fs' ) ;
4
4
const async = require ( './async' ) ;
5
- const promisify = require ( './promisify ' ) ;
5
+ const { promisify } = require ( 'util ' ) ;
6
6
7
7
const readFile = promisify ( fs . readFile ) ;
8
8
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const fs = require ( 'fs' ) ;
4
+ const { promisify } = require ( 'util' ) ;
4
5
const async = require ( './async' ) ;
5
- const promisify = require ( './promisify' ) ;
6
6
7
7
const readFile = promisify ( fs . readFile ) ;
8
8
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
const fs = require ( 'fs' ) ;
4
+ const { promisify } = require ( 'util' ) ;
4
5
const async = require ( './async' ) ;
5
- const promisify = require ( './promisify' ) ;
6
6
7
7
const readFile = promisify ( fs . readFile ) ;
8
8
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const httpGet = require ( './get-json' ) ;
4
+
5
+ const baseUrl = 'http://localhost:3000/' ;
6
+ ( async ( ) => {
7
+ const api = await httpGet ( baseUrl ) ;
8
+ for ( const resource of api . resources ) {
9
+ const data = await httpGet ( baseUrl + resource ) ;
10
+ console . log ( data ) ;
11
+ }
12
+ } ) ( ) ;
Original file line number Diff line number Diff line change 2
2
3
3
const http = require ( 'http' ) ;
4
4
5
- module . exports = ( url ) => new Promise ( ( resolve , reject ) => {
5
+ module . exports = url => new Promise ( ( resolve , reject ) => {
6
6
http . get ( url , res => {
7
7
const code = res . statusCode ;
8
8
if ( code !== 200 ) {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- module . exports = asyncFunction => ( ...args ) => (
3
+ module . exports = fn => ( ...args ) => (
4
4
new Promise ( ( resolve , reject ) => {
5
5
args . push ( ( err , result ) => {
6
6
if ( err ) reject ( err ) ;
7
7
else resolve ( result ) ;
8
8
} ) ;
9
- asyncFunction ( ...args ) ;
9
+ fn ( ...args ) ;
10
10
} )
11
11
) ;
You can’t perform that action at this time.
0 commit comments