refactor: move away from the tuple pattern
This commit is contained in:
parent
3f1dc5304c
commit
6ef11e9a27
|
@ -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 { getActivePortals } from "#portal.js";
|
||||||
|
import { CID } from "@lumeweb/libs5";
|
||||||
|
|
||||||
export async function uploadObject(
|
export async function uploadObject(
|
||||||
file:
|
file:
|
||||||
|
@ -8,11 +9,11 @@ export async function uploadObject(
|
||||||
| Uint8Array
|
| Uint8Array
|
||||||
| Blob,
|
| Blob,
|
||||||
size?: bigint,
|
size?: bigint,
|
||||||
): Promise<ErrTuple> {
|
): Promise<CID> {
|
||||||
const activePortals = getActivePortals();
|
const activePortals = getActivePortals();
|
||||||
|
|
||||||
if (!activePortals.length) {
|
if (!activePortals.length) {
|
||||||
return NO_PORTALS_ERROR;
|
throw NO_PORTALS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const portal of activePortals) {
|
for (const portal of activePortals) {
|
||||||
|
@ -31,8 +32,8 @@ export async function uploadObject(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [upload, null];
|
return upload;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_PORTALS_ERROR;
|
throw NO_PORTALS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue