Files
kay delaney bad048b7ba Performance: Standardize lodash imports to use destructured members (#33040)
* Performance: Standardize lodash imports to use destructured members
Changes lodash imports of the form `import x from 'lodash/x'` to
`import { x } from 'lodash'` to reduce bundle size.

* Remove unnecessary _ import from Graph component

* Enforce lodash import style

* Fix remaining lodash imports
2021-04-21 09:38:00 +02:00

26 lines
541 B
TypeScript

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;
}
}