File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict' ;
22
33class 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 ;
611 }
712
813 enqueue ( data ) {
9- this . array . push ( data ) ;
14+ this . # array. push ( data ) ;
1015 }
1116
1217 dequeue ( ) {
13- return this . array . pop ( ) ;
18+ return this . # array. pop ( ) ;
1419 }
1520
1621 get count ( ) {
17- return this . array . length ;
22+ return this . # array. length ;
1823 }
1924}
2025
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const arrayToQueueAdapter = ( arr ) => ( {
3+ const arrayToQueueAdapter = ( array ) => ( {
44 enqueue ( data ) {
5- arr . push ( data ) ;
5+ array . push ( data ) ;
66 } ,
77
88 dequeue ( ) {
9- return arr . pop ( ) ;
9+ return array . pop ( ) ;
1010 } ,
1111
1212 get count ( ) {
13- return arr . length ;
13+ return array . length ;
1414 }
1515} ) ;
1616
Original file line number Diff line number Diff line change @@ -10,11 +10,15 @@ class HashMap {
1010 }
1111
1212 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' ) ;
1416 }
1517
1618 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 ) ;
1822 }
1923
2024 has ( key ) {
You can’t perform that action at this time.
0 commit comments