File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +20
-11
lines changed
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
class ArrayToQueueAdapter {
4
- constructor ( arr ) {
5
- this . array = arr ;
4
+ #array = null ;
5
+
6
+ constructor ( array ) {
7
+ if ( ! Array . isArray ( array ) ) {
8
+ throw new Error ( 'Array instance expected' ) ;
9
+ }
10
+ this . #array = array ;
6
11
}
7
12
8
13
enqueue ( data ) {
9
- this . array . push ( data ) ;
14
+ this . # array. push ( data ) ;
10
15
}
11
16
12
17
dequeue ( ) {
13
- return this . array . pop ( ) ;
18
+ return this . # array. pop ( ) ;
14
19
}
15
20
16
21
get count ( ) {
17
- return this . array . length ;
22
+ return this . # array. length ;
18
23
}
19
24
}
20
25
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const arrayToQueueAdapter = ( arr ) => ( {
3
+ const arrayToQueueAdapter = ( array ) => ( {
4
4
enqueue ( data ) {
5
- arr . push ( data ) ;
5
+ array . push ( data ) ;
6
6
} ,
7
7
8
8
dequeue ( ) {
9
- return arr . pop ( ) ;
9
+ return array . pop ( ) ;
10
10
} ,
11
11
12
12
get count ( ) {
13
- return arr . length ;
13
+ return array . length ;
14
14
}
15
15
} ) ;
16
16
Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ class HashMap {
10
10
}
11
11
12
12
set ( key , value ) {
13
- this . fs . writeFileSync ( this . path + key , JSON . stringify ( value ) , 'utf8' ) ;
13
+ const name = this . path + key ;
14
+ const data = JSON . stringify ( value ) ;
15
+ this . fs . writeFileSync ( name , data , 'utf8' ) ;
14
16
}
15
17
16
18
get ( key ) {
17
- return JSON . parse ( this . fs . readFileSync ( this . path + key , 'utf8' ) ) ;
19
+ const name = this . path + key ;
20
+ const data = this . fs . readFileSync ( name , 'utf8' ) ;
21
+ return JSON . parse ( data ) ;
18
22
}
19
23
20
24
has ( key ) {
You can’t perform that action at this time.
0 commit comments