UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

26 lines (24 loc) 695 B
import { IterableX } from '../iterablex'; export class DefaultIfEmptyIterable extends IterableX { constructor(source, defaultValue) { super(); this._source = source; this._defaultValue = defaultValue; } *[Symbol.iterator]() { let state = 1; for (const item of this._source) { state = 2; yield item; } if (state === 1) { yield this._defaultValue; } } } export function defaultIfEmpty(defaultValue) { return function defaultIfEmptyOperatorFunction(source) { return new DefaultIfEmptyIterable(source, defaultValue); }; } //# sourceMappingURL=defaultifempty.mjs.map