You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
541 B
25 lines
541 B
import { cloneDeep } from 'lodash';
|
|
import { VariableModel } from 'app/features/variables/types';
|
|
|
|
export class VariableBuilder<T extends VariableModel> {
|
|
protected variable: T;
|
|
|
|
constructor(initialState: T) {
|
|
const { id, index, global, ...rest } = initialState;
|
|
this.variable = cloneDeep({ ...rest, name: rest.type }) as T;
|
|
}
|
|
|
|
withName(name: string) {
|
|
this.variable.name = name;
|
|
return this;
|
|
}
|
|
|
|
withId(id: string) {
|
|
this.variable.id = id;
|
|
return this;
|
|
}
|
|
|
|
build(): T {
|
|
return this.variable;
|
|
}
|
|
}
|
|
|