Skip to content

Commit 05cc282

Browse files
committed
use reduce to avoid type assertion
1 parent 9ae4bb7 commit 05cc282

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ad-server-cache-bun/src/ads.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,18 @@ export class AdMetadataStore {
8181
if (!results) {
8282
return [];
8383
}
84-
return results.map(([error, hash]) => {
84+
return results.reduce((acc: Array<AdMetadata>, [error, hash]) => {
8585
if (error) {
8686
throw error;
8787
}
8888
if (!hash) {
89-
return null;
89+
return acc;
9090
}
9191
if (!Value.Check(AdMetadata, hash)) {
92-
return null;
92+
return acc;
9393
}
94-
return hash;
95-
}).filter((hash) => hash !== null) as Array<AdMetadata>;
94+
acc.push(hash);
95+
return acc;
96+
}, []);
9697
}
9798
}

0 commit comments

Comments
 (0)