import { IterableX } from '../iterablex.js'; import { MonoTypeOperatorFunction } from '../../interfaces.js'; /** @ignore */ export class StartWithIterable extends IterableX { private _source: Iterable; private _args: TSource[]; constructor(source: Iterable, args: TSource[]) { super(); this._source = source; this._args = args; } *[Symbol.iterator]() { for (const x of this._args) { yield x; } for (const item of this._source) { yield item; } } } /** * Prepend a value to an iterable sequence. * * @template TSource The type of the elements in the source sequence. * @param {...TSource[]} args Elements to prepend to the specified sequence. * @returns {MonoTypeOperatorFunction} The source sequence prepended with the specified values. */ export function startWith(...args: TSource[]): MonoTypeOperatorFunction { return function startWithOperatorFunction(source: Iterable): IterableX { return new StartWithIterable(source, args); }; }