UNPKG

trainingpeaks-sdk

Version:
36 lines (35 loc) 898 B
import { ElementType, LengthUnit, } from '../../types/index.js'; export class WorkoutStructureElementBuilder { constructor() { this.element = { type: ElementType.STEP, steps: [], length: { value: 0, unit: LengthUnit.MINUTE }, begin: 0, end: 0, }; } type(type) { this.element.type = type; return this; } addStep(step) { this.element.steps.push(step); return this; } addSteps(steps) { this.element.steps.push(...steps); return this; } duration(minutes) { this.element.length = { value: minutes, unit: LengthUnit.MINUTE }; return this; } distance(value, unit = LengthUnit.KILOMETER) { this.element.length = { value, unit }; return this; } build() { return { ...this.element }; } }