@@ -118,37 +118,46 @@ const OrderedKeyValue =
118118 let count = 0 ;
119119 const orderedLogEntries : LogEntry < DagCborEncodable > [ ] = [ ] ;
120120 for await ( const entry of log . traverse ( ) ) {
121- orderedLogEntries . unshift ( entry )
122- } ;
121+ orderedLogEntries . unshift ( entry ) ;
122+ }
123123
124- let finalEntries : { key : string ; value : unknown ; position : number , hash : string } [ ] = [ ]
124+ let finalEntries : {
125+ key : string ;
126+ value : unknown ;
127+ position : number ;
128+ hash : string ;
129+ } [ ] = [ ] ;
125130 for ( const entry of orderedLogEntries ) {
126131 const { op, key, value } = entry . payload ;
127132 if ( ! key ) return ;
128133
129134 if ( op === "PUT" ) {
130- finalEntries = finalEntries . filter ( e => e . key !== key ) ;
135+ finalEntries = finalEntries . filter ( ( e ) => e . key !== key ) ;
131136
132137 const putValue = value as { value : unknown ; position ?: number } ;
133138
134139 const hash = entry . hash ;
135140
136- const position = putValue . position !== undefined ? putValue . position : - 1 ;
141+ const position =
142+ putValue . position !== undefined ? putValue . position : - 1 ;
137143 finalEntries . push ( {
138144 key,
139145 value : putValue . value ,
140146 position,
141- hash
147+ hash,
142148 } ) ;
143- count ++
149+ count ++ ;
144150 } else if ( op === "MOVE" ) {
145- const existingEntry = finalEntries . find ( e => e . key === key ) ;
151+ const existingEntry = finalEntries . find ( ( e ) => e . key === key ) ;
146152 if ( existingEntry ) {
147153 existingEntry . position = value as number ;
148- finalEntries = [ ...finalEntries . filter ( e => e . key !== key ) , existingEntry ]
154+ finalEntries = [
155+ ...finalEntries . filter ( ( e ) => e . key !== key ) ,
156+ existingEntry ,
157+ ] ;
149158 }
150159 } else if ( op === "DEL" ) {
151- finalEntries = finalEntries . filter ( e => e . key !== key ) ;
160+ finalEntries = finalEntries . filter ( ( e ) => e . key !== key ) ;
152161 }
153162 if ( amount !== undefined && count >= amount ) {
154163 break ;
@@ -169,7 +178,7 @@ const OrderedKeyValue =
169178 position : number ;
170179 } [ ] = [ ] ;
171180 for await ( const entry of iterator ( ) ) {
172- entries . push ( entry )
181+ entries . push ( entry ) ;
173182 }
174183
175184 const values : {
@@ -179,14 +188,17 @@ const OrderedKeyValue =
179188 } [ ] = [ ] ;
180189
181190 for ( const entry of entries ) {
182- const position = entry . position >= 0 ? entry . position : ( entries . length + entry . position + 1 )
191+ const position =
192+ entry . position >= 0
193+ ? entry . position
194+ : entries . length + entry . position + 1 ;
183195 values . splice ( position , 0 , {
184196 key : entry . key ,
185197 value : entry . value ,
186198 hash : entry . hash ,
187- } )
199+ } ) ;
188200 }
189-
201+
190202 return values ;
191203 } ;
192204
0 commit comments