@@ -101,7 +101,7 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
101
101
return addOperation ( { op : "DEL" , key : joinedKey , value : null } ) ;
102
102
} ;
103
103
104
- const get = async ( key : NestedKey ) : Promise < PossiblyNestedValue > => {
104
+ const get = async ( key : NestedKey ) : Promise < PossiblyNestedValue | undefined > => {
105
105
const joinedKey = typeof key === "string" ? key : joinKey ( key ) ;
106
106
const relevantKeyValues : { key : string ; value : DagCborEncodable } [ ] = [ ] ;
107
107
@@ -131,7 +131,7 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
131
131
) : Promise < string [ ] > => {
132
132
let flattenedEntries : { key : string ; value : DagCborEncodable } [ ] ;
133
133
if ( typeof keyOrObject === "string" ) {
134
- flattenedEntries = flatten ( object ) . map ( ( entry ) => ( {
134
+ flattenedEntries = flatten ( object ! ) . map ( ( entry ) => ( {
135
135
key : `${ keyOrObject } /${ entry . key } ` ,
136
136
value : entry . value ,
137
137
} ) ) ;
@@ -159,15 +159,18 @@ export const NestedApi = ({ database }: { database: InternalDatabase }) => {
159
159
} ;
160
160
for await ( const entry of log . traverse ( ) ) {
161
161
const { op, key, value } = entry . payload ;
162
+ if ( typeof key !== "string" ) continue ;
163
+
162
164
if ( op === "PUT" && ! keyExists ( key ) ) {
165
+ if ( value === undefined ) continue ;
163
166
keys [ key ] = true ;
164
167
count ++ ;
165
168
const hash = entry . hash ;
166
169
yield { key, value, hash } ;
167
170
} else if ( op === "DEL" && ! keyExists ( key ) ) {
168
171
keys [ key ] = true ;
169
172
}
170
- if ( count >= amount ) {
173
+ if ( amount !== undefined && count >= amount ) {
171
174
break ;
172
175
}
173
176
}
0 commit comments