import {Routine} from './routine'; export class Routines { constructor() { this._context = undefined; this.routines = {}; } *[Symbol.iterator]() { for (const index in this.routines) { const routine = this.routines[index]; yield routine; } } set context(context) { this._context = context; for (const routine of this) { routine.context = context; } } fromJSON(json) { for (const i in json.routines) { this.routines[i] = (new Routine()).fromJSON(json.routines[i]); } 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, }; } }