UNPKG

@omnimedia/omnitool

Version:

open source video processing tools

19 lines 665 B
import { MapG } from "@e280/stz"; import { Media } from "./media.js"; export class ResourcePool { #map = new MapG; /** store a media file (avoids duplicates via hash) */ async store(datafile) { const media = await Media.analyze(datafile); const { hash } = media.datafile.checksum; const { filename, bytes } = media.datafile; if (this.#map.has(hash)) { const alreadyExists = this.#map.require(hash); alreadyExists.filename = filename; } else this.#map.set(hash, { kind: "media", filename, bytes }); return media; } } //# sourceMappingURL=resource-pool.js.map