UNPKG

awscdk-construct-scte-scheduler

Version:

AWS CDK Construct for scheduling SCTE-35 events using the MediaLive schedule API

27 lines (26 loc) 625 B
export class UnionSerde { from; to; keys; constructor(from, to) { this.from = from; this.to = to; const keys = Object.keys(this.from); const set = new Set(keys); set.delete("__type"); this.keys = set; } mark(key) { this.keys.delete(key); } hasUnknown() { return this.keys.size === 1 && Object.keys(this.to).length === 0; } writeUnknown() { if (this.hasUnknown()) { const k = this.keys.values().next().value; const v = this.from[k]; this.to.$unknown = [k, v]; } } }