import ModMetadata from "./mod-metadata"; import ZippedModMetadataReader from "./zipped-mod-metadata-reader"; type ModMetadataFactory = (config: T) => ModMetadata; type Parser = (input: string) => T; abstract class ZippedModTextMetadataReader> extends ZippedModMetadataReader { private readonly _factory: ModMetadataFactory; private readonly _parser: Parser; protected constructor(configEntryName: string, factory: ModMetadataFactory, parser?: Parser) { super(configEntryName); this._factory = factory; this._parser = parser ?? JSON.parse; } protected loadConfig(buffer: Buffer): TConfig { return this._parser(buffer.toString("utf8")); } protected createMetadataFromConfig(config: TConfig): ModMetadata { return this._factory(config); } } export default ZippedModTextMetadataReader;