export class Extractor { private extract: (text: string) => O | null; public constructor(extract: (text: string) => O | null) { this.extract = extract; } public get(text: string) { return this.extract(text); } public or(other: Extractor) { const this_extract = this.extract; return new Extractor(text => { const r1 = this_extract(text); if (r1 !== null) return r1; else return other.extract(text); }); } }