@@ -101,7 +101,7 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
101101 return addOperation ( { op : "DEL" , key : joinedKey , value : null } ) ;
102102 } ;
103103
104- const get = async ( key : NestedKey ) : Promise < PossiblyNestedValue > => {
104+ const get = async ( key : NestedKey ) : Promise < PossiblyNestedValue | undefined > => {
105105 const joinedKey = typeof key === "string" ? key : joinKey ( key ) ;
106106 const relevantKeyValues : { key : string ; value : DagCborEncodable } [ ] = [ ] ;
107107
@@ -131,7 +131,7 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
131131 ) : Promise < string [ ] > => {
132132 let flattenedEntries : { key : string ; value : DagCborEncodable } [ ] ;
133133 if ( typeof keyOrObject === "string" ) {
134- flattenedEntries = flatten ( object ) . map ( ( entry ) => ( {
134+ flattenedEntries = flatten ( object ! ) . map ( ( entry ) => ( {
135135 key : `${ keyOrObject } /${ entry . key } ` ,
136136 value : entry . value ,
137137 } ) ) ;
@@ -159,15 +159,18 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
159159 } ;
160160 for await ( const entry of log . traverse ( ) ) {
161161 const { op, key, value } = entry . payload ;
162+ if ( typeof key !== "string" ) continue ;
163+
162164 if ( op === "PUT" && ! keyExists ( key ) ) {
165+ if ( value === undefined ) continue ;
163166 keys [ key ] = true ;
164167 count ++ ;
165168 const hash = entry . hash ;
166169 yield { key, value, hash } ;
167170 } else if ( op === "DEL" && ! keyExists ( key ) ) {
168171 keys [ key ] = true ;
169172 }
170- if ( count >= amount ) {
173+ if ( amount !== undefined && count >= amount ) {
171174 break ;
172175 }
173176 }
0 commit comments