UNPKG

@omnimedia/omnitool

Version:

open source video processing tools

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