import {Routine} from './routine'; export class Routines { static type() { return 'routines'; } constructor() { this.routines = {}; } *[Symbol.iterator]() { for (const index in this.routines) { const routine = this.routines[index]; yield routine; } } clone(other) { for (const i in other.routines) { const routine = other.routines[i]; this.routines[i] = routine.clone(); } } fromJSON(json) { for (const i in json.routines) { const routineJSON = json.routines[i]; this.routines[i] = (new Routine()).fromJSON(routineJSON); } return this; } routine(index) { return this.routines[index]; } toJSON() { const routines = {}; for (const i in this.routines) { routines[i] = this.routines[i].toJSON(); } return { type: 'routines', routines, }; } }