refactor: move away from the tuple pattern

This commit is contained in:
Derrick Hammer 2023-09-08 05:37:09 -04:00
parent 3f1dc5304c
commit 6ef11e9a27
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import { ErrTuple, NO_PORTALS_ERROR } from "#types.js";
import { NO_PORTALS_ERROR } from "#types.js";
import { getActivePortals } from "#portal.js";
import { CID } from "@lumeweb/libs5";
export async function uploadObject(
file:
@ -8,11 +9,11 @@ export async function uploadObject(
| Uint8Array
| Blob,
size?: bigint,
): Promise<ErrTuple> {
): Promise<CID> {
const activePortals = getActivePortals();
if (!activePortals.length) {
return NO_PORTALS_ERROR;
throw NO_PORTALS_ERROR;
}
for (const portal of activePortals) {
@ -31,8 +32,8 @@ export async function uploadObject(
continue;
}
return [upload, null];
return upload;
}
return NO_PORTALS_ERROR;
throw NO_PORTALS_ERROR;
}