import { BaseEnumerator } from "./BaseEnumerator";

export class WaitTimeEnumerator extends BaseEnumerator {
    private _seconds: number;

    constructor(seconds: number) {
        super();
        this._seconds = seconds;
    }

    next(value?: any): IteratorResult<any> {
        let delta = value as number;
        this._seconds -= delta;

        if (this._seconds <= 0) {
            return { done: true, value: 0 };
        } else {
            return { done: false, value: this._seconds };
        }
    }
}
