Move 'mappings' to a separate interface

This commit is contained in:
Pieter Vander Vennet 2022-07-03 13:18:05 +02:00
parent bb10f60636
commit 0146d1e4f7
4 changed files with 270 additions and 225 deletions

View file

@ -200,6 +200,24 @@ export class Concat<X, T> extends Conversion<X[], T[]> {
}
}
export class FirstOf<T, X> extends Conversion<T, X>{
private readonly _conversion: Conversion<T, X[]>;
constructor(conversion: Conversion<T, X[]>) {
super("Picks the first result of the conversion step", [], "FirstOf("+conversion.name+")");
this._conversion = conversion;
}
convert(json: T, context: string): { result: X; errors?: string[]; warnings?: string[]; information?: string[] } {
const reslt = this._conversion.convert(json, context);
return {
...reslt,
result: reslt.result[0]
};
}
}
export class Fuse<T> extends DesugaringStep<T> {
private readonly steps: DesugaringStep<T>[];