UNPKG

@yume-chan/scrcpy

Version:
36 lines 1.09 kB
function toDashCase(input) { return input.replace(/([A-Z])/g, "-$1").toLowerCase(); } const CODEC_OPTION_TYPES = { repeatPreviousFrameAfter: "long", maxPtsGapToEncoder: "long", }; export class CodecOptions { options; constructor(options = {}) { for (const [key, value] of Object.entries(options)) { if (typeof value !== "number") { throw new Error(`Invalid option value for ${key}: ${String(value)}`); } } this.options = options; } toOptionValue() { const entries = Object.entries(this.options).filter(([, value]) => value !== undefined); if (entries.length === 0) { return undefined; } return entries .map(([key, value]) => { let result = toDashCase(key); const type = CODEC_OPTION_TYPES[key]; if (type) { result += `:${type}`; } result += `=${value}`; return result; }) .join(","); } } //# sourceMappingURL=codec-options.js.map