updated createIntegrityMetadataSet to accept more flexible input types

This commit is contained in:
Nebel 2024-10-02 18:01:14 +09:00
parent 38d39e7c93
commit c3a6793e6e
Signed by: nebel
GPG key ID: 79807D08C6EF6460
2 changed files with 5 additions and 5 deletions

View file

@ -211,15 +211,15 @@ export class IntegrityMetadataSet {
}
export async function createIntegrityMetadataSet(
hashAlgorithms: HashAlgorithm[],
hashAlgorithms: ReadonlyArray<HashAlgorithm> | HashAlgorithm,
data: ArrayBuffer,
options: IntegrityMetadataSetOptions = {
getPrioritizedHashAlgorithm,
},
): Promise<IntegrityMetadataSet> {
const integrityMetadata = await Promise.all(
hashAlgorithms.map((alg) => createIntegrityMetadata(alg, data)),
const set = await Promise.all(
[hashAlgorithms].flat().map((alg) => createIntegrityMetadata(alg, data)),
);
return new IntegrityMetadataSet(integrityMetadata.join(" "), options);
return new IntegrityMetadataSet(set, options);
}

View file

@ -9,7 +9,7 @@ import {
test("instantiate a new IntegrityMetadataSet", async function () {
const res = new Response("Hello, world!");
const data = await res.arrayBuffer();
const set = await createIntegrityMetadataSet(["sha256"], data);
const set = await createIntegrityMetadataSet("sha256", data);
assert(set instanceof IntegrityMetadataSet);
});