Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | 1x 1x 1x 1x 1x 1x 4x 4x 1x 1x 2x 2x 4x 4x 4x | import { Transformation } from "../types/transformation.type";
import { DeleteProps, DeleteValueTransform } from "./transformations/delete";
import { PushProps, PushTransform } from "./transformations/push";
import { SetProps, SetTransform } from "./transformations/set";
import {
RemoveItemProps,
RemoveItemTransform,
} from "./transformations/remove-item";
import { YamlConfig, DEFAULT_YAML_CONFIG } from "./config";
export class YamlTransformationBuilder {
private readonly transforms: Transformation[] = [];
private config: YamlConfig = DEFAULT_YAML_CONFIG;
/**
* Configure YAML output options
*/
withConfig(config: YamlConfig): this {
this.config = { ...this.config, ...config };
return this;
}
/**
* Set the default quote style for string values
*/
withQuoteStyle(style: "QUOTE_SINGLE" | "QUOTE_DOUBLE" | "PLAIN"): this {
this.config.defaultStringType = style;
return this;
}
set(props: SetProps): this {
this.transforms.push(new SetTransform(props, this.config));
return this;
}
push(props: PushProps): this {
this.transforms.push(new PushTransform(props, this.config));
return this;
}
delete(props: DeleteProps): this {
this.transforms.push(new DeleteValueTransform(props, this.config));
return this;
}
removeItem(props: RemoveItemProps): this {
this.transforms.push(new RemoveItemTransform(props, this.config));
return this;
}
build(): Transformation[] {
return this.transforms;
}
}
|