import { BaseEnumerator } from "./BaseEnumerator";

export class SingleEnumerator extends BaseEnumerator {
    private _iterator: Iterator<any>;

    constructor(iterator: Iterator<any>) {
        super();
        this._iterator = iterator;
    }

    next(value?: any): IteratorResult<any> {
        if (!this._iterator) {
            return { done: true, value: undefined };
        }

        return this._iterator.next(value);
    }
}
