export interface Graph { [key: string]: T; } export class GraphIterable implements Iterable { private graph: Graph; constructor(graph: Graph) { this.graph = graph; } [Symbol.iterator](): Iterator { const keys = Object.keys(this.graph); let index = 0; return { next: (): IteratorResult => { if (index < keys.length) { return { value: keys[index++], done: false }; } else { return { value: undefined, done: true }; } }, }; } }