File tree Expand file tree Collapse file tree 5 files changed +16
-0
lines changed
Expand file tree Collapse file tree 5 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,11 @@ class ArrayToQueueAdapter extends Array {
44 enqueue ( data ) {
55 this . push ( data ) ;
66 }
7+
78 dequeue ( ) {
89 return this . pop ( ) ;
910 }
11+
1012 get count ( ) {
1113 return this . length ;
1214 }
Original file line number Diff line number Diff line change @@ -4,12 +4,15 @@ class ArrayToQueueAdapter {
44 constructor ( arr ) {
55 this . array = arr ;
66 }
7+
78 enqueue ( data ) {
89 this . array . push ( data ) ;
910 }
11+
1012 dequeue ( ) {
1113 return this . array . pop ( ) ;
1214 }
15+
1316 get count ( ) {
1417 return this . array . length ;
1518 }
Original file line number Diff line number Diff line change @@ -4,9 +4,11 @@ const arrayToQueueAdapter = arr => ({
44 enqueue ( data ) {
55 arr . push ( data ) ;
66 } ,
7+
78 dequeue ( ) {
89 return arr . pop ( ) ;
910 } ,
11+
1012 get count ( ) {
1113 return arr . length ;
1214 }
Original file line number Diff line number Diff line change @@ -8,24 +8,31 @@ class HashMap {
88 this . path = path ;
99 fs . mkdirSync ( path ) ;
1010 }
11+
1112 set ( key , value ) {
1213 this . fs . writeFileSync ( this . path + key , JSON . stringify ( value ) , 'utf8' ) ;
1314 }
15+
1416 get ( key ) {
1517 return JSON . parse ( this . fs . readFileSync ( this . path + key , 'utf8' ) ) ;
1618 }
19+
1720 has ( key ) {
1821 return this . fs . existsSync ( this . path + key ) ;
1922 }
23+
2024 delete ( key ) {
2125 this . fs . unlinkSync ( this . path + key ) ;
2226 }
27+
2328 get size ( ) {
2429 return this . keys ( ) . length ;
2530 }
31+
2632 keys ( ) {
2733 return this . fs . readdirSync ( this . path ) ;
2834 }
35+
2936 clear ( ) {
3037 this . keys ( ) . forEach ( file => {
3138 this . delete ( file ) ;
Original file line number Diff line number Diff line change @@ -7,9 +7,11 @@ class AdaptiveEmitter extends EventEmitter {
77 super ( ) ;
88 this . transformations = { } ;
99 }
10+
1011 transform ( from , to , fn ) {
1112 this . transformations [ from ] = { to, fn } ;
1213 }
14+
1315 emit ( name , ...args ) {
1416 const transform = this . transformations [ name ] ;
1517 if ( transform ) {
You can’t perform that action at this time.
0 commit comments