File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -108,5 +108,29 @@ mapImplementations.forEach((MapImplementation) => {
108108 expect ( Array . from ( map . values ( ) ) ) . toEqual ( [ 'dos' , 3 ] ) ;
109109 } ) ;
110110 } ) ;
111+
112+ describe ( '#entries' , ( ) => {
113+ beforeEach ( ( ) => {
114+ map . set ( 1 , 2 ) ;
115+ map . set ( 2 , 'dos' ) ;
116+ map . set ( 3 , 3 ) ;
117+ } ) ;
118+
119+ it ( 'should return all entries' , ( ) => {
120+ expect ( Array . from ( map . entries ( ) ) ) . toEqual ( [
121+ [ 1 , 2 ] ,
122+ [ 2 , 'dos' ] ,
123+ [ 3 , 3 ] ,
124+ ] ) ;
125+ } ) ;
126+
127+ it ( 'should update on delete' , ( ) => {
128+ expect ( map . delete ( 1 ) ) . toBe ( true ) ;
129+ expect ( Array . from ( map . entries ( ) ) ) . toEqual ( [
130+ [ 2 , 'dos' ] ,
131+ [ 3 , 3 ] ,
132+ ] ) ;
133+ } ) ;
134+ } ) ;
111135 } ) ;
112136} ) ;
Original file line number Diff line number Diff line change @@ -43,6 +43,12 @@ class TreeMap {
4343 yield node . getData ( ) ;
4444 }
4545 }
46+
47+ * entries ( ) {
48+ for ( const node of this ) {
49+ yield [ node . value , node . getData ( ) ] ;
50+ }
51+ }
4652}
4753
4854// Aliases
You can’t perform that action at this time.
0 commit comments