Commit 4e1d92a 1 parent c49e766 commit 4e1d92a Copy full SHA for 4e1d92a
File tree 6 files changed +13
-9
lines changed
09-behavioral-design-patterns
01-strategy-multiformat-config
03-template-multiformat-config
09-iterator-matrix-generator
6 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export class Config {
24
24
25
25
async save ( filePath ) {
26
26
console . log ( `Serializing to ${ filePath } ` )
27
- await fs . writeFile ( filePath , this . formatStrategy . serialize ( this . data ) )
27
+ await fs . writeFile ( filePath ,
28
+ this . formatStrategy . serialize ( this . data ) )
28
29
}
29
30
}
Original file line number Diff line number Diff line change @@ -4,7 +4,8 @@ import objectPath from 'object-path'
4
4
export class ConfigTemplate {
5
5
async load ( file ) {
6
6
console . log ( `Deserializing from ${ file } ` )
7
- this . data = this . _deserialize ( await fsPromises . readFile ( file , 'utf-8' ) )
7
+ this . data = this . _deserialize (
8
+ await fsPromises . readFile ( file , 'utf-8' ) )
8
9
}
9
10
10
11
async save ( file ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { ConfigTemplate } from './configTemplate.js'
3
3
export class JsonConfig extends ConfigTemplate {
4
4
_deserialize ( data ) {
5
5
return JSON . parse ( data )
6
- } ;
6
+ }
7
7
8
8
_serialize ( data ) {
9
9
return JSON . stringify ( data , null , ' ' )
Original file line number Diff line number Diff line change @@ -12,11 +12,11 @@ const twoWay = twoWayGenerator()
12
12
twoWay . next ( )
13
13
console . log ( twoWay . next ( 'world' ) )
14
14
15
- console . log ( 'throw():' )
15
+ console . log ( 'Using throw():' )
16
16
const twoWayException = twoWayGenerator ( )
17
17
twoWayException . next ( )
18
18
console . log ( twoWayException . throw ( new Error ( 'Boom!' ) ) )
19
19
20
- console . log ( 'return():' )
20
+ console . log ( 'Using return():' )
21
21
const twoWayReturn = twoWayGenerator ( )
22
22
console . log ( twoWayReturn . return ( 'myReturnValue' ) )
Original file line number Diff line number Diff line change @@ -4,14 +4,16 @@ export class Matrix {
4
4
}
5
5
6
6
get ( row , column ) {
7
- if ( row >= this . data . length || column >= this . data [ row ] . length ) {
7
+ if ( row >= this . data . length ||
8
+ column >= this . data [ row ] . length ) {
8
9
throw new Error ( 'Out of bounds' )
9
10
}
10
11
return this . data [ row ] [ column ]
11
12
}
12
13
13
14
set ( row , column , value ) {
14
- if ( row >= this . data . length || column >= this . data [ row ] . length ) {
15
+ if ( row >= this . data . length ||
16
+ column >= this . data [ row ] . length ) {
15
17
throw new Error ( 'Out of bounds' )
16
18
}
17
19
this . data [ row ] [ column ] = value
Original file line number Diff line number Diff line change 1
- import request from 'superagent'
1
+ import superagent from 'superagent'
2
2
3
3
// The Invoker
4
4
export class Invoker {
@@ -26,7 +26,7 @@ export class Invoker {
26
26
}
27
27
28
28
async runRemotely ( cmd ) {
29
- await request
29
+ await superagent
30
30
. post ( 'http://localhost:3000/cmd' )
31
31
. send ( { json : cmd . serialize ( ) } )
32
32
You can’t perform that action at this time.
0 commit comments