Skip to content

Commit def23a9

Browse files
committed
Permettre undefined dans toObject
1 parent 5896c70 commit def23a9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@orbitdb/nested-db",
3-
"version": "1.3.5",
3+
"version": "1.3.6",
44
"description": "Nested key-value database type for orbit-db.",
55
"author": "Julien Jean Malard-Adam",
66
"keywords": [

src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,18 @@ export const toMap = <T extends NestedValueObject>(
151151
return map as unknown as NestedObjectToMap<T>;
152152
};
153153

154-
export const toObject = <T extends NestedValueMap>(
154+
export const toObject = <T extends Map<string, DagCborEncodable | NestedValueMap | undefined>>(
155155
x: T,
156156
): NestedMapToObject<T> => {
157157
const dict = {} as NestedMapToObject<T>;
158158
for (const [key, value] of x.entries()) {
159+
if (value === undefined) continue;
159160
if (value instanceof Map) {
160161
// @ts-expect-error TODO
161162
dict[key] = toObject(value);
162163
} else {
163164
// @ts-expect-error TODO
164-
dict[key as keyof T] = value;
165+
dict[key as keyof typeof dict] = value;
165166
}
166167
}
167168
return dict;

0 commit comments

Comments
 (0)